• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

ProgrammingGAF, I need your advice (Rhythm game) (JAVA)

Status
Not open for further replies.

Mathaou

legacy of cane
I had an idea that I would 'play' my rhythm game first and have the times at which I hit the key output to the console, so I could use those values minus the hard coded in time it takes an object to reach the bar to know when I should begin their fall. I was having trouble so I changed every long to an int because it actually wasn't even that long.

Code:
//these are the hard coded in values from when I played the game myself
    public int[] aList = new int[]{
        10312, 12162, 13996, 14478, 15379, 16696, 17662, 18529, 19446, 19862, 21662, 22395, 22829, 23196, 23979, 26329, 27612, 28529, 29412, 30329, 31212, 31896, 34379, 35229, 35562, 36596, 37279, 37929, 
        39645, 41679, 45329, 45796, 46229, 46696, 51579, 52046, 52329, 55529, 56246, 57832, 58546, 58879, 59079, 59312, 59646, 59879, 60112, 60496, 60829, 61179, 61546, 63512, 64196, 64612, 65096, 
        67212, 67678, 68179, 68679, 70029, 71728, 72629, 73496, 76229, 77596, 79396, 80546, 81279, 81712, 84862, 8512, 85329, 86312, 87629, 88579, 89396, 90312, 90462  
};
.....
//this returns the time in milliseconds
public int getTime() {
    return (int) ((Sys.getTime() * 1000) / Sys.getTimerResolution());
}
.....
public void update(GameContainer c, int d) throws SlickException {
    //make every image
    if(aList[aLoc]-magicNumber==(getTime()-startTime)){
        aFList.add(new FallingObject(new Image("res/fistA.png"),WIDTH/10*2-radius-5,0-radius,radius));
        aLoc++;
    }
    //move every image
    for(FallingObject f: aFList){
        f.setY(f.getY()+4);
    }
}
Am I going about this wrong? Do you know a better way to do a rhythm game?
 

Drkirby

Corporate Apologist
You may be better off putting all those hard coded valves at the start in a text file rather then hard coding them in.
 

Makai

Member
Be aware that the timer is slightly inaccurate. It will sound wrong if you try to play dynamic sounds on top of the music.

Frame dips will ruin your song, so rein in the garbage collector.
 
Status
Not open for further replies.
Top Bottom