Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (756)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Multiple keys pressed at once! on: 2004-11-17 22:16:00
whenever a key is pressed, trigger the switch of a boolean.  Don't actually act on it until you run all of the logic of your game.

You mean like have it switch threads at such a fast rate that the human eye cannot notice that it is switching between the threads.  I understand what that does but not reall sure how to accomplish that.   No one that we seem to know, knows how to Multithread.  through our reacsurch online we kinda figured out that we mostlikly need to use the try command and sleep command.  Is this true?

thanks for your help
2  Game Development / Newbie & Debugging Questions / Re: Multiple keys pressed at once! on: 2004-11-16 02:13:13
Sorry this code sample is for one tank.  if you want our code for both tanks just ask and i'll post it here.
3  Game Development / Newbie & Debugging Questions / Multiple keys pressed at once! on: 2004-11-16 02:11:45
Yes hi

I am currently taking a AP programming class and my group of friends and i are trying to make a Tank wars game.  We are having a problem with making it so two players can move thier tank at the same time.   Here is our code so you can see what we have.

     Trivial applet that displays a string

import java.awt.*;
import java.applet.Applet;
import javax.swing.*;
import java.awt.event.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TrivialApplet extends Applet
     Image image;
     Image image2;
     Image image3;
     Image image4;
     Image image5;
     Image display;
     int x_pos = 10;                  
     int y_pos = 10;            
     private Image dbImage;
     private Graphics dbg;
    public void init()
         image = getImage(getDocumentBase(), "Tank1.2LEFT.GIF");
         image2 = getImage(getDocumentBase(), "Tank1.2UP.GIF");
         image3 = getImage(getDocumentBase(), "Tank1.2DOWN.GIF");
         image4 = getImage(getDocumentBase(), "Tank1.2RIGHT.GIF");
         image5 = getImage(getDocumentBase(), "MAP-1 copy.jpg");

     public void update (Graphics g)  
           if (dbImage == null)
                 dbImage = createImage (this.getSize().width, this.getSize().height);
                 dbg = dbImage.getGraphics();            

           dbg.setColor (getBackground());      
           dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);

           dbg.setColor (getForeground());
           paint (dbg);

           g.drawImage (dbImage, 0, 0, this);

      public boolean keyDown(Event e, int key) {
         if (key == Event.LEFT){
                 x_pos = x_pos -3;
                 display = image;
           else if (key == Event.RIGHT){
                 x_pos = x_pos +3;
                 display = image4;
           else if (key == Event.UP){
                 y_pos = y_pos -3;
                 display = image2;
           else if (key == Event.DOWN){
                 y_pos = y_pos +3;
                 display = image3;
           return true;
       public void paint(Graphics g)
         g.drawImage(image5, 0, 0, this);
         return true;
         g.drawImage(display, x_pos, y_pos, this);


Now what we want to acomplish is to make it so player one with the keys Up, down, left, and right can be pushing thier keys at the same time as player two who has the keys w, s, a, and d  without overiding the other players commands.   We have an idea that we are going to have to multi thread but don't know how to.

Also we want to have music playing in the background and sounds can you tell us how to do those as well.  

on another note we are working on making it so the tanks can fire but when the tanks fires a "Bullet" it will just pass over the other tank.  how do we make it reconize that it touched the other "Tank".

If you could help us that would be very helpfull.

Please send your hints or answers to as well as post them.

again this would be very helpfull.

Smeghead out!  
Pages: [1]
DesertCoockie (56 views)
2018-05-13 18:23:11

nelsongames (88 views)
2018-04-24 18:15:36

nelsongames (78 views)
2018-04-24 18:14:32

ivj94 (763 views)
2018-03-24 14:47:39

ivj94 (95 views)
2018-03-24 14:46:31

ivj94 (647 views)
2018-03-24 14:43:53

Solater (108 views)
2018-03-17 05:04:08

nelsongames (189 views)
2018-03-05 17:56:34

Gornova (430 views)
2018-03-02 22:15:33

buddyBro (1090 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!