Jump to content
  • Advertisement

Yar

Sign in to follow this  
  • entries
    208
  • comments
    383
  • views
    66187

Animation

Sign in to follow this  
H_o_p_s

153 views

I've started porting over my code from JavaTactics that pertains to actor animation. Here is what I came up with:
import 	java.util.ArrayList;

public class ChronoMorph {

ArrayList a;
int b,c;
boolean d;
int e,f;

public ChronoMorph(int[] aa, int[] bb) {//Graphics, Wait
a = new ArrayList();
for(int i = 0; i a.add(i,new g(aa,bb));
}
b = c = 0;
d = false;
}

public boolean u(int aa) {//Update
d = false;
e = (aa + c);
f = m();
if (e > f) {
b++;
c = 0;
if(b >= a.size())
b = 0;
u(e - f);
d = true;
} else {
c += aa;
}
return d;
}

public int g() {return ((g)a.get(b)).g;}//Get Graphical ID

public int m() {return ((g)a.get(b)).m;}//Get ms wait

class g {int g,m;public g(int gid, int ms) {g=gid;m=ms;}}
}






Oh, and here are some of the character images that I have found...
Sign in to follow this  


5 Comments


Recommended Comments

Yeah, I found an entire sprite sheet of him in isometric view... has all sorts of poses. The main ones that I will use will be the standing, walking, and jumping. I really needed the jumping pics because without them the characters look funny going from different height in the map...

Share this comment


Link to comment
I like how you've optimized your code - I was going to comment on how obfuscated it was, then I remembered function names are compiled verbatim in java [lol]

From a C++ point of view though - yuck!

Oh, and I <3 your sprites!!!

Share this comment


Link to comment
Oh god, your code burns my eyes. Now, if what the previous poster said was true, then I respect what you are doing -- but can't you do that at the end, after the code is written? Like, write it legibally, then write a program to parse your code and replace variable names? I mean....Ow.

Share this comment


Link to comment
Hehehe... Thought that I would get some good reactions out of that one. Here was the source before optimizations:

import java.util.ArrayList;

public class ChronoMorph {//IT WORKS!!!!

ArrayList List;
int CurrentFrame;
int TotalTimeWithinFrame;
boolean UpdateScreenVariable;

int TotalTimeElapsed;//UPDATE VARIABLES
int FramesTotalWait;

public ChronoMorph(int[] Graphical_ids, int[] TimeToWait) {
List = new ArrayList();
for(int i = 0; i<Graphical_ids.length; i++) {
List.add(i,new Frame(Graphical_ids[i],TimeToWait[i]));
}
TotalTimeWithinFrame=0;
UpdateScreenVariable=false;
CurrentFrame=0;
}

public boolean update(int ms) {
UpdateScreenVariable=false;
TotalTimeElapsed = (ms + TotalTimeWithinFrame);
FramesTotalWait = getMsw();
if (TotalTimeElapsed > FramesTotalWait) {
CurrentFrame++;
this.TotalTimeWithinFrame = 0;
if(CurrentFrame>=List.size())
CurrentFrame=0;
update(TotalTimeElapsed - FramesTotalWait);
UpdateScreenVariable = true;
} else {
this.TotalTimeWithinFrame += ms;
}
return UpdateScreenVariable;
}

public int getGid() {
return ((Frame)List.get(CurrentFrame)).g;
}

public int getMsw() {
return ((Frame)List.get(CurrentFrame)).m;
}

class Frame {
int g,m;
public Frame(int gid, int ms) {g=gid;m=ms;}
}
}

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!