Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 / [Newbie terminology] What are Sprites? on: 2012-06-04 11:15:18
My question is: What does the term "Sprite" mean? Huh Huh Huh

Well, I know roughly what sprites are. They are game graphics. Let me re-phase my question.

Are sprites the sources of the game graphics or the graphic instances created during the game? Huh

May be I am not making my question clear. Let's give an example.

If I have an action game, I have a bullet.jpg file as the graphic source of the bullets. Let's say I have my game character firing his/her machine gun. Multiple bullets are fired out from the gun, so there are many rendered instances of bullet.jpg on the screen. My question now is: Is the term "Sprite" referring to the image file on the file directory - bullet.jpg(source), or each rendered output(instance) of every bullet fired out during gameplay? Grin

I hope I got my question put up nice and clear. Hope any experienced people will help me out on such simple matter. Thank you in advanced
2  Game Development / Newbie & Debugging Questions / How to program updating animation? on: 2010-12-31 08:55:16
Hello all,

I am a newbie in Java game development though I have been doing general java programming for quite some time now. This post is more of a question about software engineering for game development.

One of the things that I discover I need to do a lot during game development is animation. As I was making a few mini games, a question appears and got my attention - How should I program for the "updating" animation?

I was quite used to Model-View-Controller and making ordinary Swing applications. Traditionally with Swing application, when something happens in the "Model", I want the "View" to update straight away. Similarly, when I do something with the "Controller", I want "View" to response straight away.

However it's not quite the same in game development when animation involves. Sometimes, when something happens in model, the view does not update straight away, instead, it has to go through some animation before the view catches up with the model's latest status. I just don't know what is the best way to program the updates with animations... Some advice would be great here...

For example, I have a Hero object and a Monster object. The Hero object has a attack method that will shred away Monster's health. If Monster's health reaches zero, it dies. A traditional and simplest way would be:

Class Hero {
  ...
  void attack (Monster m) {
    m.health--;
    if (m.health <= 0) {
      m.die();
    }
  }
}

As you can see, everything happens within a fraction of a second... and there's no time to wait for the animation to finish.

My thoughts on inserting animation is to have multiple threads - one for the model and one for the animation... The animation thread is looped with timed sleep intervals like many game developers would do. The model thread get suspended when certain animations are playing:

Class Hero {
  ...
  void attack (Monster m) {
    playAttackAnimation(); // falls into an infinite while loop and wait for the animation to finish
    m.health--;
    if (m.health <= 0) {
      m.playDyingAnimation (); // falls into an infinite while loop and wait for the animation to finish
      m.die();
    }
  }
  void playAttackAnimation() {
    status = HERO_ATTACKING;
    while (status == HERO_ATTACKING) { // the infinite while loop and wait for the animation thread to update status to something else
    }
  }
}

For the animation thread:

while (...) {
  ...
  switch (hero.status) {
    case Hero.HERO_ATTACKING:
      renderHeroAttack(); // how this renders depends on the value of heroAttackFrame which acts like a frame counter for the animation
      heroAttackFrame++;
      if (heroAttackFrame >= heroAttackEndFrame) {
        hero.status = HERO_STANDING; // or any other status after ATTACKING
        heroAttackFrame = 0; // reset the attack frame counter back to zero
      }
  }
}

Personally I don't think using infinite while loop is a wise way of doing animation. However on the other hand, I don't think it's a very good idea either to finish everything in the model and then pause and wait for the animation to play and catch up the latest status of the model, i.e. finish running m.health--; and m.die(); before start calling playAttackAnimation(); and m.playDyingAnimation (); . (Of course, playAttackAnimation(); and m.playDyingAnimation (); are not just empty while loops now. They handle the animations here, so there is only one thread to handle both model and animation. ) Understand what I mean here? The main point of this post basically is about how and when I should animate the updates triggered by the model or the controller...

Surely I don't want to do this:

Class Hero {
  ...
  void attack (Monster m) {
    renderAttackFrame1();
    Thread.sleep(...);
    renderAttackFrame2();
    Thread.sleep(...);
    renderAttackFrame3();
    Thread.sleep(...);
    renderAttackFrame4();
    Thread.sleep(...);
    ...
    m.health--;

    renderAttackFrameX();
    Thread.sleep(...);
    renderAttackFrameY();
    Thread.sleep(...);
    renderAttackFrameZ();
    Thread.sleep(...);
    ...

    if (m.health <= 0) {
      m.die();
      m.renderDyingFrame1 ();
      Thread.sleep(...);
      m.renderDyingFrame2 ();
      Thread.sleep(...);
      m.renderDyingFrame3 ();
      Thread.sleep(...);
      ...
    }
  }
}


Any better suggestions from anyone?
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.

Riven (2 views)
2014-07-23 21:16:32

Riven (4 views)
2014-07-23 21:07:15

Riven (5 views)
2014-07-23 20:56:16

ctomni231 (39 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (29 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!