Compare commits

..

No commits in common. "be581bbe70b2c4d0b51c193c9debef2c4200da92" and "000a5cfe909325dc25f978aaa81e48a2f3df70f7" have entirely different histories.

8 changed files with 205 additions and 725 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
.vscode/* .vscode/*
.vs/*
bin/* bin/*
src/gfx/convpng.* src/gfx/convpng.*
screenshot.png screenshot.png

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,5 @@
## Spacemania TI-84 CE Edition ## Spacemania TI-84 CE Edition
### Now almost working! ### Now almost working!
This being my first project programming in C I, quite frankly, have no clue what I'm doing. At this point, the program works fine and technically the game is playable. Enemy's die if you hit them and you die if they hit you, however, the game is extremely slow and I don't know how to fix it. I have decided to continue working on something which runs on more capable hardware and which is in a language I already know. Maybe I'll come back to this later, maybe I wont, you'll have to see. Will post a release later, for now, you can compile it for yourself with the tools from [CE-Programming](https://github.com/CE-Programming/)
Feel free to improve the code if you know how.
You can compile it for yourself with the tools from [CE-Programming](https://github.com/CE-Programming/)

View File

@ -7,11 +7,6 @@ struct Baddie {
float x; float x;
float y; float y;
} pos; } pos;
struct oldPos
{
float x;
float y;
} oldPos;
} baddies[baddieAmount]; } baddies[baddieAmount];
int spawnBaddie(float posX, float posY) int spawnBaddie(float posX, float posY)
@ -36,12 +31,7 @@ int updateBaddie(int i)
if (!(baddies[i].pos.x <= (0 - 32))) if (!(baddies[i].pos.x <= (0 - 32)))
{ {
baddies[i].pos.x -= speed; baddies[i].pos.x -= speed;
if ((abs(baddies[i].oldPos.x - baddies[i].pos.x) >= 1) || (abs(baddies[i].oldPos.y - baddies[i].pos.y) >= 1))
{
gfx_Sprite(baddie, baddies[i].pos.x, baddies[i].pos.y); gfx_Sprite(baddie, baddies[i].pos.x, baddies[i].pos.y);
baddies[i].oldPos.x = baddies[i].pos.x;
baddies[i].oldPos.y = baddies[i].pos.y;
}
return 1; return 1;
} }
else else

View File

@ -9,11 +9,6 @@ struct Bullet
float x; float x;
float y; float y;
} pos; } pos;
struct oldPos
{
float x;
float y;
} oldPos;
} bullets[bulletAmount]; } bullets[bulletAmount];
int spawnBullet(float posX, float posY) int spawnBullet(float posX, float posY)
@ -38,12 +33,7 @@ int updateBullet(int i)
if (!(bullets[i].pos.x >= (LCD_WIDTH + 16))) if (!(bullets[i].pos.x >= (LCD_WIDTH + 16)))
{ {
bullets[i].pos.x += speed; bullets[i].pos.x += speed;
if ((abs(bullets[i].oldPos.x - bullets[i].pos.x) >= 1) || (abs(bullets[i].oldPos.y - bullets[i].pos.y) >= 1))
{
gfx_Sprite(bullet, bullets[i].pos.x, bullets[i].pos.y); gfx_Sprite(bullet, bullets[i].pos.x, bullets[i].pos.y);
bullets[i].oldPos.x = bullets[i].pos.x;
bullets[i].oldPos.y = bullets[i].pos.y;
}
return 1; return 1;
} }
else else

View File

@ -1,40 +0,0 @@
// Variables for collision detection
float distance = 0;
float difference[2];
int a;
// Check collisions
void checkCollision() {
for (i = 0; i < (baddieAmount - 1); i++)
{
// Collision baddie x bullet
for (a = 0; a < (bulletAmount - 1); a++)
{
//// Difference x
difference[0] = (baddies[i].pos.x + (32 / 2)) - (bullets[a].pos.x + (16 / 2));
//// Difference y
difference[1] = (baddies[i].pos.y + (32 / 2)) - (bullets[a].pos.y + (16 / 2));
// Calculate diffence
distance = sqrt(pow(difference[0], 2) + pow(difference[1], 2));
if (!baddies[i].dead && !bullets[a].dead && distance <= 11)
{
bullets[a].dead = true;
baddies[i].dead = true;
}
}
// Collision baddie x player
//// Difference x
difference[0] = (baddies[i].pos.x + (32 / 2)) - (player.pos.x + (32 / 2));
//// Difference y
difference[1] = (baddies[i].pos.y + (32 / 2)) - (player.pos.y + (32 / 2));
// Calculate diffence
distance = sqrt(pow(difference[0], 2) + pow(difference[1], 2));
if (!baddies[i].dead && distance <= 15)
{
// Gameover
}
}
}

View File

@ -15,19 +15,15 @@
// set global vars // set global vars
const int bulletAmount = 5; const int bulletAmount = 5;
const int baddieAmount = 12; const int baddieAmount = 32;
int spriteActive = 0; int spriteActive = 0;
int gamestate = 0;
float speed = 0.5; float speed = 0.5;
int i; int i;
float t;
float dt;
// Include entity headers // Include entity headers
#include "player.h" #include "player.h"
#include "bullet.h" #include "bullet.h"
#include "baddie.h" #include "baddie.h"
#include "collision.h"
#include "controls.h" #include "controls.h"
void setup() void setup()
@ -36,6 +32,8 @@ void setup()
/* Initialize the 8bpp graphics */ /* Initialize the 8bpp graphics */
gfx_Begin(); gfx_Begin();
dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
dbg_Debugger();
/* Set up the palette for our sprites */ /* Set up the palette for our sprites */
gfx_SetPalette(sprites_pal, sizeof_sprites_pal, 0); gfx_SetPalette(sprites_pal, sizeof_sprites_pal, 0);
@ -94,8 +92,6 @@ void main(void)
} }
checkCollision();
// Redraw player if position has changed or if a bullet has been fired // Redraw player if position has changed or if a bullet has been fired
updatePlayer(spriteActive); updatePlayer(spriteActive);

View File

@ -13,9 +13,9 @@ struct Player
} oldPos; } oldPos;
} player; } player;
void updatePlayer(int spriteActive) void updatePlayer(int bulletsAlive)
{ {
if ((abs(player.oldPos.x - player.pos.x) >= 1) || (abs(player.oldPos.y - player.pos.y) >= 1) || spriteActive == 1) if ((abs(player.oldPos.x - player.pos.x) >= 1) || (abs(player.oldPos.y - player.pos.y) >= 1) || bulletsAlive == 1)
{ {
gfx_Sprite(spaceship, player.pos.x, player.pos.y); gfx_Sprite(spaceship, player.pos.x, player.pos.y);
player.oldPos.x = player.pos.x; player.oldPos.x = player.pos.x;