Compare commits
No commits in common. "be581bbe70b2c4d0b51c193c9debef2c4200da92" and "000a5cfe909325dc25f978aaa81e48a2f3df70f7" have entirely different histories.
be581bbe70
...
000a5cfe90
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
.vscode/*
|
||||
.vs/*
|
||||
bin/*
|
||||
src/gfx/convpng.*
|
||||
screenshot.png
|
||||
|
845
obj/main.src
845
obj/main.src
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,5 @@
|
||||
## Spacemania TI-84 CE Edition
|
||||
### 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.
|
||||
|
||||
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/)
|
||||
Will post a release later, for now, you can compile it for yourself with the tools from [CE-Programming](https://github.com/CE-Programming/)
|
||||
|
||||
|
||||
|
12
src/baddie.h
12
src/baddie.h
@ -7,11 +7,6 @@ struct Baddie {
|
||||
float x;
|
||||
float y;
|
||||
} pos;
|
||||
struct oldPos
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} oldPos;
|
||||
} baddies[baddieAmount];
|
||||
|
||||
int spawnBaddie(float posX, float posY)
|
||||
@ -36,12 +31,7 @@ int updateBaddie(int i)
|
||||
if (!(baddies[i].pos.x <= (0 - 32)))
|
||||
{
|
||||
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);
|
||||
baddies[i].oldPos.x = baddies[i].pos.x;
|
||||
baddies[i].oldPos.y = baddies[i].pos.y;
|
||||
}
|
||||
gfx_Sprite(baddie, baddies[i].pos.x, baddies[i].pos.y);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
12
src/bullet.h
12
src/bullet.h
@ -9,11 +9,6 @@ struct Bullet
|
||||
float x;
|
||||
float y;
|
||||
} pos;
|
||||
struct oldPos
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} oldPos;
|
||||
} bullets[bulletAmount];
|
||||
|
||||
int spawnBullet(float posX, float posY)
|
||||
@ -38,12 +33,7 @@ int updateBullet(int i)
|
||||
if (!(bullets[i].pos.x >= (LCD_WIDTH + 16)))
|
||||
{
|
||||
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);
|
||||
bullets[i].oldPos.x = bullets[i].pos.x;
|
||||
bullets[i].oldPos.y = bullets[i].pos.y;
|
||||
}
|
||||
gfx_Sprite(bullet, bullets[i].pos.x, bullets[i].pos.y);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
10
src/main.c
10
src/main.c
@ -15,19 +15,15 @@
|
||||
|
||||
// set global vars
|
||||
const int bulletAmount = 5;
|
||||
const int baddieAmount = 12;
|
||||
const int baddieAmount = 32;
|
||||
int spriteActive = 0;
|
||||
int gamestate = 0;
|
||||
float speed = 0.5;
|
||||
int i;
|
||||
float t;
|
||||
float dt;
|
||||
|
||||
// Include entity headers
|
||||
#include "player.h"
|
||||
#include "bullet.h"
|
||||
#include "baddie.h"
|
||||
#include "collision.h"
|
||||
#include "controls.h"
|
||||
|
||||
void setup()
|
||||
@ -36,6 +32,8 @@ void setup()
|
||||
|
||||
/* Initialize the 8bpp graphics */
|
||||
gfx_Begin();
|
||||
dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
|
||||
dbg_Debugger();
|
||||
|
||||
/* Set up the palette for our sprites */
|
||||
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
|
||||
updatePlayer(spriteActive);
|
||||
|
||||
|
@ -13,9 +13,9 @@ struct Player
|
||||
} oldPos;
|
||||
} 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);
|
||||
player.oldPos.x = player.pos.x;
|
||||
|
Loading…
Reference in New Issue
Block a user