Browse Source

Add player state

master
Forest Belton 2 years ago
parent
commit
7355280ea5
4 changed files with 34 additions and 11 deletions
  1. +8
    -7
      src/map.c
  2. +4
    -4
      src/map.h
  3. +3
    -0
      src/player.c
  4. +19
    -0
      src/player.h

+ 8
- 7
src/map.c View File

@ -3,6 +3,7 @@
#include <string.h>
#include "game.h"
#include "player.h"
#include "sdk/hardware.h"
#include "vram.h"
@ -30,7 +31,8 @@ void map_load(map_t *map) {
rSCX = INIT_SCX;
rSCY = INIT_SCY;
// TODO: Update player state
PLAYER.x = (MAP.spawn_x - MAP.camera_x) * 8;
PLAYER.y = (MAP.spawn_y - MAP.camera_y) * 8;
memcpy(VRAM_TILE_PTR(TILE_INDEX_BACKGROUND), (uint8_t *)MAP.tile_ptr,
MAP.tile_size);
@ -56,12 +58,11 @@ void map_update(void) {
pending_row_dest = 0;
}
// TODO: Make it work
/* if (pending_col_dest != 0) {
vram_enqueue_mem_xfer(pending_col_dest, &pending_col[0],
sizeof pending_col);
pending_col_dest = 0;
} */
if (pending_col_dest != 0) {
vram_enqueue_mem_xfer(XFER_TYPE_COL, pending_col_dest, &pending_col[0],
sizeof pending_col);
pending_col_dest = 0;
}
}
static void map_enqueue_row(uint16_t vram_ptr, int8_t x0, int8_t y0) {

+ 4
- 4
src/map.h View File

@ -12,10 +12,10 @@ typedef struct {
uint16_t collision_ptr;
int8_t map_width;
int8_t map_height;
uint8_t spawn_x;
uint8_t spawn_y;
uint8_t camera_x;
uint8_t camera_y;
int8_t spawn_x;
int8_t spawn_y;
int8_t camera_x;
int8_t camera_y;
} map_t;
extern map_t MAP; //!< The current game map

+ 3
- 0
src/player.c View File

@ -0,0 +1,3 @@
#include "player.h"
player_t PLAYER;

+ 19
- 0
src/player.h View File

@ -0,0 +1,19 @@
#ifndef IS_PLAYER_H_
#define IS_PLAYER_H_
#include <stdint.h>
#define PLAYER_INV_SIZE 32
typedef struct {
uint8_t x;
uint16_t y;
uint16_t vy;
uint8_t dir;
uint8_t state;
// TODO: Define inventory if there's time
} player_t;
extern player_t PLAYER;
#endif

Loading…
Cancel
Save