Applet Game Programming - player movement

HI Java Experts,
I have a very simple question applet game programming - jdk 1.02.
Let's say you have a player on the applet window. He can move right and left.
Naturally you have an image representing the player. When the player moves left you present an image loop with him running left. And vice versa for running right.
Of course when he stops moving you just want to show a still image.
What do you guys feel is the best technique for that situation ?
Stephen

Hi Thanks for the advice.
I'm under the impression that if I used jdk1.4
everybody who wanted to play the game would have to go
through the trouble of downloading something . If
that is so, then i would like to stick with 1.02 to
have the widest possible audience.Use Java Web Start to deploy it as an application instead of an Applet. If your program is really cool, people will download the JDK 1.4 to use it. Then we will have more java users in the world :)
By the way i have a URL perhaps someone could look > at the source code and give additional suggestions
you can make sonic the hedge hog run and jump
http://www.swebdev.com/Adventure.html
That code has some good points. I like the nice object oriented flow of it. However, the way he sets up the Thread is all wrong. He uses yield and sleep, you would want to set up this using wait() and notifyAll() calls if you want to make it more interesting.
Right now i'm trying to address the issue of how to
reverse the image for when the player is running the
opposite way -- ? perhaps a separate thread in 1.02
might be an answer? I would be glad to hear all kinds
of suggestions on the sample code seen thereYou shouldn't need a separate thread just to reverse the image. If your little guy is already in his own thread, just switch the image that is displayed when the player hits the opposite direction key.
Think of threads like puppets, and you are the puppet master. Your little guys is a puppet, so he should be in his own thread. You can make him do whatever you want from your thread (the master) by pulling strings (changing globals, and message passing)
Wow... Thats a really good analogy... I just thought that up :)

Similar Messages

  • Looking beginner applet game programmer

    Hi people. Iam quite new to java and currently learning stuff about how to program java games in an applet. So iam looking for a partner to start a little game/project together and hopefully we can learn stuff of each other and get a half decent game at the end aswell. I only really have 1 requirement.
    Please know atleast the fundementals of applet game programming
    Other information
    Age : 16
    Location : UnitedKingdom
    Chat : MSN Messenger
    Please get in contact with me through e-mail or MSN Chat. e-mail is : [email protected]
    Thanks alot.

    >>
    The age/location aren't requirements--the OP is describing himself.Yes, I think it's a bit too early in the day for my attempt at humor:);)
    kindly apologizing
    walkenNo need to apologize. Your humor is always welcome. If this is too early, I'd hate to see what's too late. ;)

  • Multiplayer game programming - Code of a basic server

    I'm a beginner in multiplayer game programming and I'm looking for the code of a basic server for a multiplayer game. I don't mind which kind of game (I mean: chess, ping-pong, battlenet...) The important thing is the code pattern abnd the server structure.
    Could anyone help me?

    If you want to have a look at a generic multi-threaded server, check out the Java networking tutorial.. there's a basic example server that responds to a "Knock knock, who's there?" conversation.. you can start off with it..
    Of course it's not a game server but you could try sticking in a game engine to maintain the game world and change the user sessions to a proper game protocol.. e.g. sending key strokes or joystick movements. You could also get the server to send player and enemy positions etc...
    Good luck!

  • Object Oriented AS3 game programming - where do I start?

    I’m a programmer familiar with object oriented
    programming, with experience in C++, C# and the MS Visual Studio
    development environment.
    I’ve been tasked to create a web based game using Flash
    CS4 and ActionScript3. I am new to Flash, ActionScript and game
    programming. I have never used previous versions of Flash or
    ActionScript.
    The game will be a single player role playing game. The
    player will have the ability to create an avatar.
    The player will move the avatar from screen to screen based
    on button clicks or drag and drop onto objects in the current
    screen.
    Players must register, and player information will be stored
    in a database backend. Additonal data will be saved to the backend
    database during game play.
    The saved data will be based on player actions in various
    screens, and in some cases data entered in a form on a screen.
    For a first pass a stick figure avatar and screens containing
    simple buttons and simple objects to drag the avatar to will be
    sufficient. I would like to store data in a database tracking
    date/time information, e.g. date/time each screen is
    entered/exited.
    Any links to articles, or better yet, sample code showing
    these concepts would be greatly appreciated – Thanks

    Start is relative term. It took me too long just to find out
    how to "hello the world" so I'll save you that work.
    In Flash (Note: I'm using CS3 but I doubt this part of the
    menu has changed that much)
    1) File -> New -> ActionScript File
    2) Paste in the following:
    package junkdir {
    import flash.display.Sprite;
    public class junktest extends Sprite {
    public function junktest() {
    trace("Hello world");
    3) Save as some_folder/junkdir/junktest // obviously create
    new folder 'junkdir' during this process
    4) File -> New -> Flash File (Action Script 3.0)
    5) In the properties field labeled 'document class' type in
    junkdir.junktest // THIS WAS THE OBSCURE PART
    If the properties field did not automatically open then
    manually open with: Window -> Properties -> Properties
    6) Save this file as 'junk' in some_folder
    7) Control -> Test Movie
    "Hello World" appears in the Output Window. (This also can be
    opened manually)
    Read whatever Adobe online docs gets you involved quickly, I
    like the display objects just for a quick visual high. Most code
    will cut and paste into this 'junk' framework.
    I recommend two O'Reilly books: Actions Script 3.0 Quick
    Reference Guide by Stiller, Shupe, deHaan & Richardson and
    Essential ActionScript 3.0 by Collin Moock.
    Hope this helps. Good luck.

  • Game Programming Errors

    I'm trying to make up a game program for a school progect, and I'm having some troubles with it.
    I'm having multiple errors in the following areas: 1. Find symbol contructor/method. 2. Inconvertible types. 3. Jump[] in GameSrc.Player cannot be applied [boolean].

    Well thats kinda general... In my opinion java is a great language. Just not for games usually. Also what kind of game? 2d or 3d? I would recommend checking out unity for 3D games. I have used it and it is a great tool for people looking to make 3D games without as much work. Plus it supports execution in a browser like an applet kindof. For 2D i usually use flash as it greatly simplifies the process. If your hearts set on Java start off with this- http://www.tutorialized.com/view/tutorial/2D-Java-Platform-Game/10145

  • Connecting more than java file in an applet game

    I'm creating an applet game that consists of more than one java file, how can I connect those java files in one main program?....And also, how can I hide the first window of my applet and show the next window of my applet from the different java file?
    Can anyone give me a simple code that consists of 2 java files connected in one program and that can hide the first window when I click a button there and opens the next window....please help me with this....thanks....

    Components and windows in java have setVisible(boolean) methods. You can hide them by calling setVisible(false). Later you can make them visible again by calling setVisible(true).

  • Mobile Game Programming

    Hey All,
    I am a decent Java programmer but in last few days I found Java Game Programming intresting and has strong future for ones career.
    I wanted to know what do Expert over here have to say about this ?
    and
    Where do I need to start In order to get to know about it ?(I mean under Java).
    Thanx
    Messy

    I suggest you move to this forum and ask your question again.
    http://forum.java.sun.com/category.jspa?categoryID=23

  • Game program - simon sez

    I have a simple game program call simon sez. I have the code completely
    written, but i cant figure out why its not working. I have the area
    in the program that is not working right and have add ********* where
    the problem area is. Can anyone figure out what ive done wrong here???
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.lang.*;
    import sun.audio.*; //import the sun.audio package
    import java.io.*;
    public class SimonMain extends Applet implements ActionListener {
    SimonButton[] simonb = new SimonButton[4];
    SimonButton[] navb = new SimonButton[2];
    SimonButton gob = new SimonButton("GO");
    Label level;
    int levelc;
    int[] levelarray = new int[10];
    int playmode = 1;
    int arraycount=0;
    int whichbutton=0;
    AudioClip snd1;
    AudioClip snd2;
    AudioClip snd3;
    AudioClip snd4;
    AudioClip right;
    AudioClip wrong;
         //Initialize the applet
    public void init() {
    levelc=1;
    snd4=getAudioClip(getDocumentBase(), "three.wav");
    snd3=getAudioClip(getDocumentBase(), "two.wav");
    snd2=getAudioClip(getDocumentBase(), "one.wav");
    snd1=getAudioClip(getDocumentBase(), "zero.wav");
    right=getAudioClip(getDocumentBase(), "right.wav");
    wrong=getAudioClip(getDocumentBase(), "wrong.wav");
    level = new Label("Choose Level: "+Integer.toString(levelc) );
    add(level);
    for(int count=0; count<4;count++)
    simonb[count] = new SimonButton(Integer.toString(count));
    simonb[count].ColorButton(Color.black );
    simonb[count].ColorFont(Color.white);
    simonb[count].addActionListener(this);
    add(simonb[count]);
    for(int count=0; count<2;count++)
    if(count==0)
    navb[count] = new SimonButton("<");
    if(count==1)
    navb[count] = new SimonButton(">");
    navb[count].addActionListener(this);
    add(navb[count]);
    gob.addActionListener(this) ;
    add(gob);
    public void paint(Graphics g) {
    g.drawString ("Simon Sez: Choose your level using arrow buttons and click go to play.Have FUN!!!",10,50);
    public void actionPerformed(ActionEvent event) {
    //test.setText("Button number is " + buttonCaption);
    String command = event.getActionCommand();
         //if (command.equals("Push")){
    if (command == "GO")
    playmode=3;
    switch(playmode)
    case 1: //This is choose level mode
    if (command == "<" )
    if(levelc==1);
    else
    levelc--;
    level.setText("Level: "+Integer.toString(levelc) );
    if (command == ">" )
    if(levelc==10);
    else
    levelc++;
    level.setText("Level: "+Integer.toString(levelc) ) ;
    break;
    case 2: //This is play mode
    //This is where it wont get past my if statement???????????????????????????
    if ( "0"==command)
         {     level.setText("WORKIng"+command);
    simonb[0].ColorFont(Color.red);
    for(int count=0;count<100000000;count++)
              snd1.play();
    simonb[0].ColorFont(Color.white );
    whichbutton=1;
    if((levelarray[arraycount]==whichbutton))
    if(arraycount+1==levelc)
    { right.play();
    playmode=1;
    break;
    arraycount++;
    else
    {   wrong.play();
    arraycount=0;
    if ("1" == command)
    simonb[1].ColorFont(Color.yellow);
    for(int count=0;count<100000000;count++)
              snd2.play();
    simonb[1].ColorFont(Color.white );
    whichbutton=2;
    if((levelarray[arraycount]==whichbutton))
    if(arraycount+1==levelc)
    { right.play();
    playmode=1;
    break;
    arraycount++;
    else
    {   wrong.play();
    arraycount=0;
    if (command == "2" )
    simonb[2].ColorFont(Color.blue);
    for(int count=0;count<100000000;count++)
              snd3.play();
    simonb[2].ColorFont(Color.white );
    whichbutton=3;
    if((levelarray[arraycount]==whichbutton))
    if(arraycount+1==levelc)
    { right.play();
    playmode=1;
    break;
    arraycount++;
    else
    {   wrong.play();
    arraycount=0;
    if (command == "3" )
    simonb[3].ColorFont(Color.pink);
    for(int count=0;count<100000000;count++)
              snd4.play();
    simonb[3].ColorFont(Color.white );
    whichbutton=4;
    if((levelarray[arraycount]==whichbutton))
    if(arraycount+1==levelc)
    { right.play();
    playmode=1;
    break;
    arraycount++;
    else
    {   wrong.play();
    arraycount=0;
    level.setText(command ) ;
    break;
    case 3: //This is generate mode
    arraycount=0;
    whichbutton=0;
    playmode=2;
    for(int count=0;count<levelc;count++)
    levelarray[count]=1+ (int) (Math.random() *4);
    level.setText(Integer.toString(levelarray[count]) );
    for(int count=0;count<levelc;count++)
    if(levelarray[count]==1)
    simonb[0].ColorFont(Color.red);
    for(int countr=0;countr<100000000;countr++)
              snd1.play();
    simonb[0].ColorFont(Color.white );
    if(levelarray[count]==2)
    simonb[1].ColorFont(Color.yellow);
    for(int county=0;county<100000000;county++)
    snd2.play();
    simonb[1].ColorFont(Color.white );
    if(levelarray[count]==3)
    simonb[2].ColorFont(Color.blue);
    for(int countb=0;countb<100000000;countb++)
              snd3.play();
    simonb[2].ColorFont(Color.white );
    if(levelarray[count]==4)
    simonb[3].ColorFont(Color.pink);
    for(int countp=0;countp<100000000;countp++)
              snd4.play();
    simonb[3].ColorFont(Color.white );
    playmode=2;
    } //end of for loop
    playmode=2;
    break;
         //Get Applet information
    public String getAppletInfo() {
              return "Applet Information";
         //Get parameter info
    public String[][] getParameterInfo() {
              return null;
    import java.awt.*;
    import java.awt.event.*;
    public class SimonButton extends Button implements ActionListener{
    public SimonButton(String label) {
    this.setLabel(label) ;
    public void actionPerformed(ActionEvent event) {
    public void ColorButton(Color color){
    this.setBackground(color);
    public void ColorFont(Color color) {
    this.setForeground(color );
    public void paint(Graphics g) {

    you need to replace all occurrances in your code of:
    if(".." == command)....
    with:
    if("..".equalsIngnoreCase(command))...
    When doing string comparison, the equality operator doesn't work. Use the provided method instead

  • What do you think of my applet game

    Over the last couple days, I made a java applet game. It is all complete except for the highscores. I am planning on doing some sort of global highscores and since I have little experience with internet programming, it is going to take a little while.
    Let me know what you think!
    http://www.geocities.com/scottrick49/targeteer/targeteer.html

    First of all I wanted to say that I like the game but I still think there is room to improve.
    To begin with yes, I think you've got way to many circles going in the start.
    If you had maybe 7 circles with higher speed I would think it more of a challenge or do as turingpest says and ramp up the number of circles.
    When I click the mouse button everything stops for a maybe 250 msec and then jumps to a new location, while it makes it more difficult I though it mainly annoying.
    One thing I would like to see in the game is if you remove the white corners of the circles and makes them explode in the color that they are.
    Adding sound would greatly benefit the game.
    Another thing that TuringPest points out, try making a credits part or something where you show any info about yourself.
    Another idea would be to give the circles different scores and when you've got enough score and accuracy you reach a new level.
    Something in the manner of adding time to the bar when you hit a circle and remove when you miss might be fun and as the difficulty increases you lose time faster.
    That's about what I can think of right now, but as I said, I actually enjoyed playing it :P

  • Game programming

    I am new to game programming and J2ME. how can i integrate animated clips and application using J2ME>

    Well thats kinda general... In my opinion java is a great language. Just not for games usually. Also what kind of game? 2d or 3d? I would recommend checking out unity for 3D games. I have used it and it is a great tool for people looking to make 3D games without as much work. Plus it supports execution in a browser like an applet kindof. For 2D i usually use flash as it greatly simplifies the process. If your hearts set on Java start off with this- http://www.tutorialized.com/view/tutorial/2D-Java-Platform-Game/10145

  • About server in game programming

    hi,
    from what i know, we need a web server like tomcat or blazix to make other people can access our web. but my problem is like this..... i develop a game programming that need a server to control the player, so that mean now i have 2 server...... but when people acces my web, they cannot connect with my game server, so they cannot play the game..... so what should i do to make people can access my web and play the game?

    I presume this is about how to have a game run in the background on the server, outside of the web requests the user made to get to the game in the first place.
    What it comes down to is, you need some way to get the data back, asynchronously or pseudo-asynchronously. You have a few options...
    (1) Run a process on the server separate to the web server, which opens the game server socket, and does all the game stuff. Simplest solution.
    (2) Make a little servlet which initialises when your webapp starts up, and the init() method starts a thread, which opens the game server socket, and does all the game stuff. A little harder, but better because it will work even if you don't have a shell to the web server (e.g. if you're on a hosting provider who has given you just an FTP.)
    (3) Make a little servlet to perform the actual game functions, and either poll at regular intervals or have the servlet itself send the data back as a continuous stream. I personally like this solution the best, and it doesn't require a thread to sit there on the server wasting a thread, but it does make a single HTTP request last for a rather long time and also proxies can screw around with the data.
    Hope this helped somehow...

  • General Game Programming Questions

    Hey All,
    I'm a reformed C# / VB.Net MMOPG game programmer who want's to take a crack at making MMORPG's using Java. Mainly because I'm tired of paying the big $$$ for M$'s products when I'm finding Java has a nice assortment of high quality RAD tools and the such for next to nothing, if not free. The only free IDE's for the .Net platform at the moment is a still too early in beta (buggy) to be productive with. Anyways after buying a couple of Java books and knocking them out in a week's time, I'm feeling pretty confident about making Java work for me. I do however have a few questions that the books I purchased failed to answer so here they are..
    Is it possible to compile Java applications (game clients in my case) in a stand alone executable form? I would like a install system where users can just install my game client without them having to worry about having the latest versions of Java ,etc, ie.. I want it to be a easy one click install application.. Does Java offer this? That was another thing that turns me off about the .Net platform, many people don't want to take the time to install the .Net runtime just to check out my game applications...
    I was wondering how Java handles Images, Does Java package up all your images into a .Jar file? A game client can have 100's of sprite sheets, mesh's, skins, etc, ie.. Say I were too make a Applet game client, how would java handle all the images? Would the players download the images while the applet loads?
    Well thats really all I wanted to know.... Thanks In Advanced...

    If you do a search on the forums for "java exe" or something similar, you will probably find about a billion posts asking and answering the same question. The answer is yes, but you will of course make the game windows dependent. Also I think the executable turns out to be quite large and doesn't work without its quircks... a better approach is to install the java runtime with the install of your game. User would never even notice.
    As far as how java handles images, for an applet the images will be downloaded with the applet, but will not be loaded until called upon in the program. You can package all the images into a jar file, or you can just leave them in a directory/directories, although packaging them into one jar would be faster due to downloading only one file and compression.

  • Choppy player movement

    I have coded an enging for a smooth-scrolling, top-down third person view online game, and I am making many things server side to eliminate security risks. Every time the client presses an arrow key, it sends the direction to the server, which in turn changes the players coordinates, and sends them back to the player. The client has a thread to repaint the map at every 10 milliseconds.
    I have also made a thread with a timer to send out the coordinates of all the players on one map to all the players on that same map. The problem is, even with a timer of this.wait(10), the player movement is still choppy.
    I was wondering if there were any way to do this (other than the way I proposed), or if there is any way to eliminate the choppy movement of the player.

    Well that's strange because people who have downloaded it from Youtube and played locally (including me) don't find it choppy at all.  The video only becomes choppy when playing on Youtube, and that's only for some viewers.  People either find it choppy or completely smooth.
    http://forum.videohelp.com/threads/363688-Youtube-video-choppy-during-camera-movement-for- some-viewers?p=2314056
    http://forums.afterdawn.com/t.cfm/f-4/youtube_video_choppy_during_playback_for_some_viewer s-973920/
    http://forum.videohelp.com/threads/363096-Embedded-video-smoother-than-actual-Youtube?p=23 08460#post2308460

  • I recently downloaded a 10.6.8 update and a game program has now been reduced in size.  It's specifications are set for full screen, but it is about 1/4 of the size.  Any ideas how to fix?

    I recently downloaded a 10.6.8 update and a game program has now been reduced in size.  It's specifications are set for full screen, but it is about 1/4 of the size.  Any ideas how to fix?

    Hi, I have got the same problem but all is 1/4 the size have you fixed it?

  • I have vlc player movies on my external hard drive; can i watch these on the apple ipad?

    i have vlc player movies on my external hard drive; i normally watch them on an windows laptop; can i watch these on the apple ipad?

    <edited>
    There's a vlc streamer app in the app store, but you would need to also install the streamer helper on the device where the movies reside. This works between my macbook and my ipad, but if you cannot access the external drive and install the helper file, then probably not

Maybe you are looking for

  • Ipod touch 4g will not wall charge after update

    just bought an ipod touch 4g and when i updated it the ipod would no longer charge from any usb wall plug. the only way it will charge is from the computer wich is a huge issue for me becouse i travel alot and i have and apple wall charger so i dont

  • After updating Firefox to version 12.0, I can no longer get my web-based help desk software to follow hyperlinks.

    Our help-desk is internal, secure website. We have used Firefox for our help desk software browser since we purchased the software. But after updating to version 12, clicking on a hyperlink no longer works but only for the help desk software. Pre-ver

  • Using Text fields in SWT

    Well, the people over on the Swing forum didn't like when I put this over there, and I can't find a dedicated SWT forum, so I hope I can get an answer over here... In my GUI (developed using SWT), I have a Text field called date. It appears in the wi

  • Balance Sheet account in a Purchase Requisition

    Can I use a Balance Sheet account on a Purchase Requisition?  We currently do that and would like to be able to keep doing it.  However, no matter what BS account I try to use it says "GL Account XXX cannot be used".   Also/Or what Account Assignment

  • Help with Date

    Hello Everyone, I have a report with 3 parameters such as startdate, enddate and country When the user set the startdate and enddate as null and entering only country then I want to display the startdate and enddate as yesterday's date and if enddate