Nah I changed it up, they initilize at the begining, i.e. int Ship_1X=190;
Code:
int main(void) {
full_screen_color(COLOR_BLACK);
drawship();
while(true) {
if(PRGM_GetKey() == KEY_PRGM_MENU) {
keymenu();
}
GetKey(&key);
if (keydown(KEY_PRGM_UP)) {
Y_Move--;
} else if (keydown(KEY_PRGM_DOWN)) {
Y_Move++;
} else if (keydown(KEY_PRGM_LEFT)) {
X_Move--;
} else if (keydown(KEY_PRGM_RIGHT)) {
X_Move++;
}
//Move update
if (Y_Move) {
DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
Ship_1Y=Ship_1Y+Y_Move;
drawship(); }
if (X_Move) {
DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
Ship_1X=Ship_1X+X_Move;
drawship(); }
//Screen boundaries scroll
if (Ship_1X<7) {
DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
Ship_1X=389;
drawship(); }
if (Ship_1X>389) {
DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
Ship_1X=7;
drawship(); }
if (Ship_1Y<7) {
DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
Ship_1Y=217;
drawship(); }
if (Ship_1Y>217) {
DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
Ship_1Y=7;
drawship(); }
}
return 0;
}
This is my main code so far, notice the ship is just a circle right now. I am drawing a black circle where the prevoius circle was to "erase" it. Is there a better way to erase the ship (while possibly keeping background?).
Next problem, where it says "move update" it is supposed to keep moving by adding the X and Y move increments, but odly it only increments when I push the arrow (actually any) keys. How come? (drawship updates Bdisp_PutDisp_DD();, so that isn't the problem.
Thanks for the support.
I have the suspicion that
Code:
if(PRGM_GetKey() == KEY_PRGM_MENU) {
keymenu();
}
pauses the execution until key press, but I am not sure.