Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  Java Game APIs & Engines / Java 2D / Re: Java demo needs testers on: 2002-12-02 08:40:13
Yeah, from what I've read, Java's a little new at grasping onto the Graphics frontier.

It's a fun and wild ride anyway Smiley
2  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-12-01 13:04:48
Thank you Smiley That sounds a lot like what Captain was saying.

*** UPDATE ***

Just thought I'd come back to edit this and say THANK YOU to everyone that helped Smiley I finally got the idea through my thick skull and I have several little guys on the screen all moving randomly at their own speeds without any flickering Smiley
3  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-12-01 02:46:49
Ok, now that I've fixed that little problem... now I have encountered another! Tongue

I removed the paint calls from the Thread. So now the flickering has stopped, but if I have another thread for another NPC running, the screen flickers really badly and alternates between the two characters.

I guess what I'm getting at is how would I animate other objects on the screen? Do I keep track of how many "frames" I have drawn and draw certain pieces at certain times, or do I need these separate threads for each one?

All I want is to be able to animate multiple things on the screen.
4  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-12-01 00:44:05
Yeah that's what I figured! This is my *first* time dealing with Threads, so I'm goofing up in all kinds of ways!

I think the best thing to do is just to have the thread calculate which image to display next, and change that image in the main program rather than dealing with the graphics object.

If I run two of these threads, the screen flickers all over the place!!!

I'm going to try modifying the thread to just change the image and have the paint method in the main program determine when it should refresh itself.
5  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-11-30 16:35:06
Ok another question!!! Smiley

I still have flickering even though DoubleBuffering is set to True on the swing components that I'm using.

What happens is that every few seconds the character blinks (disappears then reappears very quickly).

The following is the run method from my Thread class (AnimateSprite extends Thread):

   method:  run()
   purpose: Handles the determination of the next image, sets up
            the new graphics object properties and passes it back
            to the paint() method in the main program.

  public void run()
    // If the thread is in running mode, then calculate
    // the next image to be displayed by the program
      // First image
      if (mode == MODE_ON)
        background = Toolkit.getDefaultToolkit().getImage(firstimage);
        //System.out.println("Printing player_old.gif");
        mode = MODE_OFF;
      // Second image
        background = Toolkit.getDefaultToolkit().getImage(secondimage);
        //System.out.println("Printing player2.gif");
        mode = MODE_ON;

      // Repaint the scene to clear what was there last

      // Draw the new image
      g.drawImage(background, xpos, ypos, mainprog);

      // Put the thread to sleep for the specified amount of time
      // in the sleep duration variable
      catch (InterruptedException e)
    // If we are no longer running, we want to repaint the scene
    if (!running)
6  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-11-30 15:08:35
Ah ok... sounds fairly simple I guess Tongue

What I did this morning was extend the Thread class and let that determine how often it renders the next image in a sequence of images to produce the effect of animation.

I pass the thread a timeslice (milliseconds), the main program, the main program's graphics object, and a string name.

I calculate what should be shown and when and if it should stop running after a specific time. It manipulates the graphics object and passes it back to the main program's paint method, which then paints everything.

This works so far... it isn't very robust, so I need to modify it a bit, but it sounds close to what you're talking about... unless I'm totally off Tongue
7  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-11-30 12:37:27
Well, considering I have other things going on in my main program, I can't call sleep in there, because it causes EVERYTHING to sleep.

I think that I am going to need to extend the thread object Sad
8  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-11-29 21:12:46
Actually, would anyone have a really simplistic example of how to animate something?

In VB, I used a timer... but I'm not sure if that's the way to go here or not.

Meaning, I can make my own timer object for each NPC and set the delay on it, but it probably isn't the best way of accomplishing this delay between frames.
9  Java Game APIs & Engines / Java 2D / Re: Animated NPCs on: 2002-11-29 13:56:17
That's a good idea, thank you Smiley

I'm a little new at doing this in Java... I jumped over from Visual Basic, so... ick Smiley hehe.

I need to figure out what this VolatileImage thing is that everyone is raving about. I've just been painting to the background of JPanels so far...
10  Java Game APIs & Engines / Java 2D / Animated NPCs on: 2002-11-29 13:46:43
I've been stuck on one thing, and this will most likely come off as an extremely stupid question, but I thought I would give it a shot Smiley

I want to have animated characters on my screen, but if I do this, I have to loop and call repaint() all of the time even when my own character isn't moving.

This means I can't have any messages go to the screen, because they'll be wiped off everytime.

What  I'm planning on doing is:

1. Painting the tiles (water, ground, path, grash, etc.).
2. Painting objects (trees, treasure chests, people).

The people will be special tile objects that will have their own animation sequences so they look like they're waddling, sleeping, or doing something in their area.

Should I just paint them all to the screen with everything else and loop their animations and call "repaint()" all of the time, or should I create a label or panel object the size of the tile and have that panel object run it's own paint() method?
Pages: [1]
EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

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

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

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

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

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

Solater (175 views)
2018-03-17 05:04:08
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!