Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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: Need help with sprite cycles on: 2011-06-21 23:21:53
Damn, thanks a lot, there's no way I would of been able to come up with that by myself. I don't have much time today, but I will ahve a good look at your Class tomorrow, and see what I can come up with.

Just a quick question about organizing 2D games. Should each level have it's own Class, or is it best just to have one humongous Board Class? When it comes to soundeffects, I assume these would be simple return methods inside their respective Classes. So for example a MachineGun Class would hold all the sounds for this gun, instead of one one Sound Class that holds everything.

Thanks again for your help, I thought I was doomed with static images for all my 2D games!

Mike
2  Java Game APIs & Engines / Java 2D / Re: Need help with sprite cycles on: 2011-06-21 17:01:24
Thanks for the reply,

So what you are saying is I should create a new "Animation Class" which will control the character and enemy walk cycles. Roughly what methods should I have, and how do run through 6 sprites using a Swing Timer (In my Board Class) with a 5ms update. I am worried that the sprites will updated so fast, they will not be noticable.

I have seen a lot of talk about something called a "Thread." Do I need to use it? Do I use BufferedImage[] to store the six sprites? I have no idea what a "full MVC approach." A little more detail in your anwser(s) would be greatly appriciated.

Sorry for all the questions, but all I am able to do right now is a simple 2D game with a character, bulltes, enemies, and collision.

Mike
3  Java Game APIs & Engines / Java 2D / Need help with sprite cycles on: 2011-06-21 09:08:28
Hi guys,

I am a java noob, so please bear with me. For the past two weeks, I have found it difficult to cycle through images. I am Working on a simple 2D game, where I need the character to "walk". I have four Classes, Board, Character,Enemy, and Main(runs program).

In the Character Class, this is a part of the method I have:

public void keyPressed(KeyEvent e)

int key = e.getKeyCode():

   if(key == KeyEvent.VK_RIGHT){
   dx=1

   //need to cycle through 6 images here!


}

When I press the Right key, I need to have the character "walk" through 6 images, then, if I press the key again, the same needs to happen.

In the Board Class, I am using a Swing Timer with an update of 5ms.


This is a bit of an aside, but my Board Class is balooning into hundreds of lines of code to support all the "if" statments for enemies, and that's just the first screen! Is this normal? If I continue at this rate, at the end of the program, I will probably have a Board Class with thousands of lines of code.

Please help out a noob,

Mike
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (34 views)
2013-05-17 21:29:12

alaslipknot (42 views)
2013-05-16 21:24:48

gouessej (72 views)
2013-05-16 00:53:38

gouessej (71 views)
2013-05-16 00:17:58

theagentd (79 views)
2013-05-15 15:01:13

theagentd (74 views)
2013-05-15 15:00:54

StreetDoggy (116 views)
2013-05-14 15:56:26

kutucuk (140 views)
2013-05-12 17:10:36

kutucuk (140 views)
2013-05-12 15:36:09

UnluckyDevil (149 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.092 seconds with 21 queries.