#18914 - darknet - Thu Apr 08, 2004 5:08 am
Hey everyone, I am having a minor problem with my the beginnings of my gradius clone, I believe with the organization of my code.
To start things off, I wanted to just have my ship move around the screen and shoot its laser. The ship and the laser are separate sprites, and everything seems to be okay except that when I shoot the laser and move my ship at the same time, there is a notable slowdown with the ships movement.
Since there are no enemies yet, when I shoot a laser I simply want it to go from the nose of the ship to the end of the screen, which it does, and the code below is the only way I could get that to work....
I hope that code snippet explains what I am doing properly. Also included in that handleCollisions function is the up,down,left,right movements of the ship, which was omitted from my explanation above.
Thanks very much for any response, I truly appreciate it.
-Mike
To start things off, I wanted to just have my ship move around the screen and shoot its laser. The ship and the laser are separate sprites, and everything seems to be okay except that when I shoot the laser and move my ship at the same time, there is a notable slowdown with the ships movement.
Since there are no enemies yet, when I shoot a laser I simply want it to go from the nose of the ship to the end of the screen, which it does, and the code below is the only way I could get that to work....
Code: |
//this is in the handleCollisions function.... if(pressed(B_BUTTON) ) { //init laser to go right off of the front of the user ship ship_laser.xRight = (user.xRight+13); ship_laser.y = (user.yTop+1); //for now just go across the screen, later do collision //detection HERE for enemy ship intersections while( (ship_laser.xRight) < 240) { ship_laser.xRight = ship_laser.xRight + 1; moveSprite(&sprites[4], ship_laser.xRight, ship_laser.y); updateSpriteMemory(); } ship_laser.xRight = (user.xRight+13); } ....the main loop then looks like so: while(gameRunning) { //the function above handleMovementsAndCollisions(); //for now just move the user ship moveSprite(&sprites[0], user.xRight, user.yTop); updateSpriteMemory(); waitForVSync(); } |
I hope that code snippet explains what I am doing properly. Also included in that handleCollisions function is the up,down,left,right movements of the ship, which was omitted from my explanation above.
Thanks very much for any response, I truly appreciate it.
-Mike