2020-08-08 00:40:00 -04:00
|
|
|
#include <string.h>
|
|
|
|
#include "../include/input.h"
|
|
|
|
#include "../include/toolbox.h"
|
|
|
|
#include "../include/memmap.h"
|
|
|
|
#include "../include/types.h"
|
|
|
|
#include "../include/memdef.h"
|
2020-08-08 20:16:34 -04:00
|
|
|
#include "../include/point.h"
|
|
|
|
#include "../include/velocity.h"
|
|
|
|
#include "../include/playerObject.h"
|
2020-08-11 18:44:22 -04:00
|
|
|
#include "../include/map.h"
|
2020-08-12 00:13:56 -04:00
|
|
|
#include "../include/camera.h"
|
2020-08-11 18:44:22 -04:00
|
|
|
|
2020-08-08 00:40:00 -04:00
|
|
|
#include "../sprites/player.h"
|
2020-08-11 18:44:22 -04:00
|
|
|
#include "../sprites/block.h"
|
2020-08-12 00:13:56 -04:00
|
|
|
#include "../sprites/spike.h"
|
2020-08-08 00:40:00 -04:00
|
|
|
|
|
|
|
OBJ_ATTR obj_buffer[128];
|
|
|
|
OBJ_AFFINE *obj_aff_buffer= (OBJ_AFFINE*)obj_buffer; // Object affine-buffer
|
|
|
|
|
|
|
|
int main() {
|
2020-08-12 00:13:56 -04:00
|
|
|
memcpy(pal_obj_mem, blockPal, blockPalLen);
|
2020-08-08 00:40:00 -04:00
|
|
|
memcpy(&tile_mem[4][0], playerTiles, playerTilesLen);
|
2020-08-11 18:44:22 -04:00
|
|
|
memcpy(&tile_mem[4][4], blockTiles, blockTilesLen);
|
2020-08-12 00:13:56 -04:00
|
|
|
memcpy(&tile_mem[4][8], spikeTiles, spikeTilesLen);
|
2020-08-08 00:40:00 -04:00
|
|
|
|
|
|
|
oam_init(obj_buffer, 128);
|
|
|
|
|
|
|
|
REG_DISPCNT= DCNT_OBJ | DCNT_OBJ_1D;
|
|
|
|
|
2020-08-10 16:04:44 -04:00
|
|
|
playerObject player = createPlayerObject(&obj_buffer[0], &obj_aff_buffer[0],0, 0);
|
2020-08-13 14:24:02 -04:00
|
|
|
player.camera = createCamera(-10, 0);
|
|
|
|
int currentGroundLevel = 140;
|
|
|
|
int currentXLevel = 1;
|
2020-08-08 20:16:34 -04:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
vid_vsync();
|
2020-08-13 14:24:02 -04:00
|
|
|
player.camera.x += 1;
|
2020-08-08 20:16:34 -04:00
|
|
|
key_poll();
|
|
|
|
|
2020-08-13 14:24:02 -04:00
|
|
|
if (player.camera.x % 16 == 15) {
|
|
|
|
currentXLevel++;
|
|
|
|
}
|
|
|
|
|
2020-08-08 20:16:34 -04:00
|
|
|
if ((key_is_down(KEY_A) || key_hit(KEY_A)) && !player.isJumping) {
|
|
|
|
player.vel.dy -= 9 << FIX_SHIFT;
|
|
|
|
}
|
2020-08-08 00:40:00 -04:00
|
|
|
|
2020-08-13 14:24:02 -04:00
|
|
|
//updatePlayer(&player, 80);
|
2020-08-10 16:04:44 -04:00
|
|
|
obj_affine_copy(obj_aff_mem, player.affine, 1);
|
|
|
|
obj_copy(obj_mem, player.obj, 1);
|
2020-08-11 18:44:22 -04:00
|
|
|
|
2020-08-12 00:13:56 -04:00
|
|
|
OBJ_ATTR blockObject, spikeObject;
|
|
|
|
obj_set_attr(&blockObject,
|
|
|
|
ATTR0_SQUARE,
|
|
|
|
ATTR1_SIZE_16,
|
|
|
|
ATTR2_PALBANK(0) | 4
|
|
|
|
);
|
|
|
|
obj_set_attr(&spikeObject,
|
|
|
|
ATTR0_SQUARE,
|
|
|
|
ATTR1_SIZE_16,
|
|
|
|
ATTR2_PALBANK(0) | 8
|
|
|
|
);
|
|
|
|
int x, y;
|
|
|
|
for (int i = 0; i < 9; i++) {
|
|
|
|
for (int j = 0; j < 15; j++){
|
|
|
|
x = (j * 16);
|
|
|
|
y = (i * 16);
|
|
|
|
applyCameraShift(&player.camera, &x, &y);
|
|
|
|
if (map1[i][j] == 1) {
|
2020-08-13 14:24:02 -04:00
|
|
|
if (j == currentXLevel) {
|
|
|
|
updatePlayer(&player, 16 * i - 16);
|
|
|
|
}
|
2020-08-12 00:13:56 -04:00
|
|
|
obj_set_pos(&blockObject, x, y);
|
2020-08-13 14:24:02 -04:00
|
|
|
obj_copy(obj_mem + (16 * i + j) + 1, &blockObject, 1);
|
2020-08-12 00:13:56 -04:00
|
|
|
}
|
|
|
|
else if (map1[i][j] == 2) {
|
|
|
|
obj_set_pos(&spikeObject, x, y);
|
2020-08-13 14:24:02 -04:00
|
|
|
obj_copy(obj_mem + (16 * i + j) + 1, &spikeObject, 1);
|
2020-08-11 18:44:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-08 20:16:34 -04:00
|
|
|
}
|
2020-08-08 00:40:00 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|