Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
/*****************************************************************
   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
   while(running)
    {
      // First image
     if (mode == MODE_ON)
      {
        background = Toolkit.getDefaultToolkit().getImage(firstimage);
        //System.out.println("Printing player_old.gif");
       mode = MODE_OFF;
      }
      // Second image
     else
      {
        background = Toolkit.getDefaultToolkit().getImage(secondimage);
        //System.out.println("Printing player2.gif");
       mode = MODE_ON;
      }

      // Repaint the scene to clear what was there last
     mainprog.repaint();

      // 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
     try{
        Thread.sleep(sleeptime);
      }
      catch (InterruptedException e)
      {}
    }
   
    // If we are no longer running, we want to repaint the scene
   if (!running)
    {
      mainprog.repaint();
    }
  }
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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (18 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (46 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56

mitcheeb (71 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!