I am writing a program for my GBA course at uni and I am looking for a bit of help if anyone can offer it :).
I am trying to built a basic space faring game and I have been able to produce 25 stars on the screen using a array set and get them to randomly position them on the screen:-
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include "gba.h"
//int x = rand()%480;
//int y = rand()%400;
int starX[50];
int starY[50];
int game_running = 1;
// The entry point for the game
int main()
{
// Put the display into bitmap mode 3, and enable background 2.
REG_DISPCNT = MODE4 | BG2_ENABLE;
// Sets colour palette
SetPaletteBG(1, RGB(31, 31, 31)); //Set colour for stars and cross-hair to white
SetPaletteBG(0, RGB(0, 0, 0)); //Set colour for background to black for page flipping
//Sets stars in random positions on screen
int i;
for ( i = 0; i < 50; i++) //Generates stars for 0 to 25
{
starX[i] = rand()%SCREEN_WIDTH; //Random position generated on x-axis
starY[i] = rand()%SCREEN_HEIGHT; //Random position generated on y-axis
PlotPixel8(starX[i], starY[i], 1); //Plots initial stars on their random points
}
Now, I am making my stars move to simulate a cross-hair I have on my screen moving. Due to the size limitations of the GBA screen, I am now needing to delete any of the stars in the array that go off the edge of the screen and have them redrawn on the other side or another position depending on which way the stars are moving and also how they are moving. I am able to get the moving part done (already implemented in another part of the code) but I just don't know how to delete and redraw parts of the array.
Anyone able to help with this is would be much appreciated.