Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (565)
Games in Android Showcase (152)
games submitted by our members
Games in WIP (607)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java 2D Fighting game  (Read 5400 times)
0 Members and 1 Guest are viewing this topic.
Offline Swattkidd7

Junior Devvie

Exp: 8 years

« Posted 2008-03-18 04:04:07 »

Ok well since i have about 120 views and no replies im guessing there is something wrong with my question.

Here is a more specific question i have, When doing animation would it be wise to have the player class have an Array of images for the right walking, and an array of images for the left walking, and then in the update function use another array called "currentArray" or w.e (which will be set when player is set to move right or left)..

Also, i seem to have trouble creating an Image array, i remember doing it before but cannot anymore. I feel like a noob but something like this isnt working.

Image[] anim = new Image[5]

anim[0] = insertWayToGetImage;
Offline Swattkidd7

Junior Devvie

Exp: 8 years

« Reply #1 - Posted 2008-03-18 04:38:40 »

Offline Swattkidd7

Junior Devvie

Exp: 8 years

« Reply #2 - Posted 2008-03-22 16:18:45 »

First post UPDATED.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

« JGO Spiffy Duke »

Medals: 21
Projects: 10

Age of Conquest makes your day!

« Reply #3 - Posted 2008-03-22 21:39:49 »

I would create two classes. One is the Player class that defines what your player is doing. For example:
enum Action {NA, LEFT, RIGHT, JUMP};

Then second, you have the PlayerSprite class which renders the player on the screen. You could do it as described: have an array of images for each type of actions:
Action action = player.getAction();
if (action == Action.LEFT) {
  // render correct image for left...

The Player class doesn't know anything about images. It just purely contains the player information. The PlayerSprite will need a timer to identify the correct image (in the series) to render it onto the screen.

Offline Coinerson

Junior Devvie

Introducing the world's cutest zombie, Timmy

« Reply #4 - Posted 2008-03-24 22:14:27 »

Your probably going to want to create an Animation class too otherwise its going to get very unwieldy.
Offline DMastaGX

Senior Newbie

« Reply #5 - Posted 2008-06-15 16:46:12 »

Make a Player Object that contains an Animation. and inside it have a Method that changes the Animation when a certain Button is pressed. Make sure all the Animations are loaded as soon as the program starts to run.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (10 views)
2015-04-01 18:27:05

ags1 (27 views)
2015-03-31 10:55:12

theagentd (13 views)
2015-03-27 23:08:20

wxwsk8er (54 views)
2015-03-20 15:39:46

Fairy Tailz (48 views)
2015-03-15 21:52:20

Olo (29 views)
2015-03-13 17:51:59

Olo (33 views)
2015-03-13 17:50:51

Olo (40 views)
2015-03-13 17:50:16

Olo (44 views)
2015-03-13 17:47:07

ClaasJG (61 views)
2015-03-10 11:36:42
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27 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!