Jump to content
  • Advertisement

monp

Member
  • Content Count

    108
  • Joined

  • Last visited

Community Reputation

100 Neutral

About monp

  • Rank
    Member
  1. I have a bin file that I need to open and and get hex data from certain offsets and put it into a text file and use a shift-jis table to have it show the japanese to be able to translate it and then insert the changed data. How would I go about doing this in python?
  2. I am using Apache 2.2 and so far I have the hello world scripts working from the book I am reading, but I am having problems whenever I use this simple form one. #!c:/strawberry/perl/bin/perl.exe use strict; use CGI; print header, start_html("Simple Form in CGI"), start_form, "Enter your name: ", textfield("name"), sumbit, end_form, hr, end_html(); exit;
  3. monp

    String into characters.

    I am trying to take user input, turn the letters into ASCII and modify them and convert them back letters and put the string back together. Right now I have it where it will put into ASCII and then I tested to see if I changed the number. I don't know where to go from here. #include <iostream> #include <string> int main() { std::string input; char a[255]; std::cin >> input; int s = input.size(); int charbuf[s]; for(int i = 0; i < s; i++) { a = input; } std::cout << input.size() << std::endl; charbuf[0] = (int) a[0]; charbuf[1] = (int) a[1]; charbuf[2] = (int) a[2]; charbuf[3] = (int) a[3]; charbuf[4] = (int) a[4]; std::cout << charbuf[1] << "unmodified" << std::endl; charbuf[1] += 5; std::cout << charbuf[1] << "Modified" << std::endl; return 0; } Edit: I have worked more on it and this is what I have so far. It works currently. #include <iostream> #include <string> int main() { std::string input; char a[255]; std::cin >> input; int s = input.size(); int charbuf[s]; char cback[s]; std::string s1, s2, s3, s4, s5; std::string result; for(int i = 0; i < s; i++) { a = input; } std::cout << input.size() << std::endl; charbuf[0] = (int) a[0]; charbuf[1] = (int) a[1]; charbuf[2] = (int) a[2]; charbuf[3] = (int) a[3]; charbuf[4] = (int) a[4]; charbuf[1] += 1; charbuf[2] += 2; charbuf[3] += 3; charbuf[4] += 4; cback[0] = (char) charbuf[0]; cback[1] = (char) charbuf[1]; cback[2] = (char) charbuf[2]; cback[3] = (char) charbuf[3]; cback[4] = (char) charbuf[4]; s1 = cback[0]; s2 = cback[1]; s3 = cback[2]; s4 = cback[3]; s5 = cback[4]; result = s1 + s2 +s3 + s4 + s5; std::cout << result << std::endl; return 0; } [Edited by - monp on November 16, 2010 3:12:54 PM]
  4. How would I go about taking a user's input (string) and split it up into individual characters. I am trying mess with encrypting a simple string.
  5. I am trying to load a bunch of images onto the screen in random positions but it is only loading one copy of the image. import javax.swing.*; import java.awt.*; import java.awt.Image; import java.net.*; import java.util.*; import java.awt.Toolkit; class Zombie extends JComponent { int zSpawn; Random pos = new Random(); int xpos = pos.nextInt(635) + 5; int ypos = pos.nextInt(475) + 5; Image image; URL file; public Zombie(int Spawn) { zSpawn = Spawn; Toolkit toolkit = Toolkit.getDefaultToolkit(); file = getClass().getResource("/assets/Zombie.jpg"); image = toolkit.getImage(file); } public void paintComponent(Graphics g) { for(int i = 0; i < zSpawn; i++) { g.drawImage(image,xpos,ypos,this); } } } and here is the main. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ParavolaTEST { public static void main(String[] args) { JFrame frame = new JFrame("PO Zombie Loading Test"); frame.add(new Zombie(20)); frame.setSize(640,480); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } [Edited by - Zahlman on October 3, 2010 7:33:12 PM]
  6. monp

    [Java] Loading Images

    Yes, right now I am trying to load a small animation into my application.
  7. monp

    [Java] Loading Images

    Now with this how would I go about loading an image then having repaint load a different image?
  8. monp

    [Java] Loading Images

    Ok. Thanks for all of your help.
  9. monp

    [Java] Loading Images

    Alright I got that working, but when I load the program the image does not show up. Here is the main part. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Paravola { public static void main(String[] args) { JFrame frame = new JFrame("Paravola Outbreak"); frame.add(new ImageLoader2()); frame.setSize(640,480); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } and here is the fixed code. import javax.swing.*; import java.awt.*; import java.awt.Toolkit; import java.awt.Image; import java.net.*; class ImageLoader2 extends JComponent { URL file; Image image; public void ImageLoader2() { Toolkit toolkit = Toolkit.getDefaultToolkit(); file = getClass().getResource("test.jpg"); image = toolkit.getImage(file); } public void paintComponent(Graphics g) { int x = 0; int y = 0; g.drawImage(image,x,y,this); } }
  10. I am trying to load an image but I am receiving two errors, cannot find symbol on Class URL, also cannot find symbol variable image. import javax.swing.*; import java.awt.*; import java.awt.Toolkit; import java.awt.Image; class ImageLoader extends JComponent { public void ImageLoader() { Toolkit toolkit = Toolkit.getDefaultToolkit(); URL file = getClass().getResource("test.jpeg"); Image image = toolkit.getImage(file); } public void paintComponent(Graphics g) { int x = 0; int y = 0; g.drawImage(image,x,y,this); } }
  11. monp

    Error compiling

    This is from the book it tells you how to do it without using ant also. Creating an Executable .jar File Finally, when you're ready to pass out your game to friends, the last thing you want is to give them arcane instructions on how to run the code. Telling another programmer to type something like this at the command line might be okay: java com.brackeen.javagamebook.tilegame.GameManager But the casual user might not even know what a command line is or even what to do if problems occur. It's probably a good idea to make it easier by creating an executable .jar file. With an executable .jar file, all the user has to do is double-click the .jar file, and the game starts right up. Your programmer friends would probably appreciate the time it saves them as well. If you're unfamiliar with what a .jar file is, it's a Java archive file—basically just a container for a group of classes. All the classes for your game are stored in the .jar file, which is usually compressed. To make the .jar file executable, you specify which class to run in the .jar's manifest file. The manifest file is called META-INF/MANIFEST.MF inside the .jar. For this platform game, the manifest file looks something like this: Manifest-Version: 1.0 Main-Class: com.brackeen.javagamebook.tilegame.GameManager When you double-click a .jar file, the Java VM starts up and looks at the .jar file's manifest. If the Main-Class attribute is found, it runs the specified class. If there is no manifest or the Main-Class attribute doesn't exist, the VM just pretends that nothing happened and exits. If you're using the jar tool to create .jar files, first create a manifest file in a text editor and then use the -m option to add the manifest file to your .jar. If you're using Ant to build .jar files, Ant can create the manifest file automatically and add it to the .jar. Listing 5.15 shows a sample Ant target that creates an executable .jar file for the game.
  12. I am still following the book and cannot compile this into a class because I am receiving a cannot find symbol error for Thread t = new Thread(this); import javax.swing.*; import java.awt.*; import java.awt.event.*; class GuiCore2 extends JComponent implements MouseMotionListener, ActionListener { String message; int m_x = 125; int m_y = 95; JButton button; int colorIndex; static Color[] colors = {Color.black, Color.red, Color.blue, Color.green}; boolean blinkState; public GuiCore2(String msg) { message = msg; button = new JButton("Change Colors"); setLayout(new FlowLayout()); add(button); button.addActionListener(this); addMouseMotionListener(this); Thread t = new Thread(this); t.start(); } public void paintComponent(Graphics g) { g.setColor(blinkState ? getBackground() : currentColor()); g.drawString(message, m_x, m_y); } public void mouseDragged(MouseEvent e) { m_x = e.getX(); m_y = e.getY(); } public void mouseMoved(MouseEvent e) { } public void actionPerformed(ActionEvent e) { if(e.getSource() == button) { changeColor(); } } synchronized private void changeColor() { if(++colorIndex == colors.length) { colorIndex = 0; } setForeground(currentColor()); repaint(); } synchronized private Color currentColor() { return colors[colorIndex]; } public void run() { try { while(true) { blinkState = !blinkState; repaint(); Thread.sleep(300); } } catch(InterruptedException e) { } } }
  13. Wow I can't believe I missed that, thanks.
  14. I am doing the tutorials from the book Learning Java and I am having trouble finding out why my button that is suppose to change the foreground color is not working. Any help is appreciated. Gui2.class import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Gui2 { public static void main(String[] args) { JFrame frame = new JFrame("Gui Loaded"); frame.add(new GuiCore2("Core has been loaded!")); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(640, 480); frame.setVisible(true); } } GuiCore2.class class GuiCore2 extends JComponent implements MouseMotionListener, ActionListener { String message; int m_x = 125; int m_y = 95; JButton button; int colorIndex; static Color[] colors = {Color.black, Color.red, Color.blue, Color.green}; public GuiCore2(String msg) { message = msg; button = new JButton("Change Colors"); setLayout(new FlowLayout()); add(button); button.addActionListener(this); addMouseMotionListener(this); } public void paintComponent(Graphics g) { g.drawString(message, m_x, m_y); } public void mouseDragged(MouseEvent e) { m_x = e.getX(); m_y = e.getY(); } public void mouseMoved(MouseEvent e) { } public void actionPerformed(ActionEvent e) { if(e.getSource() == button) { changeColor(); } } synchronized private void changeColor() { if(++colorIndex == colors.length) { colorIndex = 0; setForeground(currentColor()); repaint(); } } synchronized private Color currentColor() { return colors[colorIndex]; } }
  15. monp

    [Java] Compiling Error.

    Ok I see what you mean but the message from Mcomponent doesn't display with the program runs.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!