Skip to content

Commit

Permalink
small improvements, removed old files
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattferguson committed Jul 28, 2022
1 parent d482fca commit 3a30bc5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 55 deletions.
Binary file modified 2048.gb
Binary file not shown.
11 changes: 1 addition & 10 deletions make.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
lcc -Wa-l -Wl-m -Wf--debug -Wl-y -Wl-w -c -o game.o ./src/main.c
lcc -Wa-l -Wl-m -Wf--debug -Wl-y -Wl-w -o 2048.gb game.o

@REM del *.o
@REM del *.map
@REM del *.lst
@REM del *.sym
@REM del *.asm
@REM del *.cdb
@REM del *.ihx
@REM del *.adb
lcc -Wa-l -Wl-m -Wf--debug -Wl-y -Wl-w -o 2048.gb game.o
1 change: 1 addition & 0 deletions src/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ UINT8 row = 0;
UINT8 col = 0;
UINT16 score = 0;
UINT8 filled_blocks = 0;

UBYTE moved = 0;
UBYTE winner = 0;

Expand Down
9 changes: 3 additions & 6 deletions src/config.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#ifndef CONFIG_H
#define CONFIG_H

#define BUTTON_DELAY 100 // add delay between button presses
#define SCREEN_DELAY 150

// screen in 8px chunks
#define GRID_HEIGHT 18
#define GRID_WIDTH 20

// window states
#define WIN_X 7
#define PLAY_WIN_Y 130
#define TUT_WIN_Y 10
#define SPLASH_WIN_Y 80
#define WIN_FOOTER 130
#define WIN_HALF_SCREEN 80
#define WIN_FULL_SCREEN 0

// logo
#define LOGO_SIZE 35
Expand Down
4 changes: 2 additions & 2 deletions src/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ const unsigned char font_tiles[] =
#define BKG 1

// font settings
#define FONT_MEMORY_START 36
#define FONT_MEMORY_START (LOGO_SIZE)
#define FONT_SIZE 38
#define FONT_CHAR_START (1 + FONT_MEMORY_START)
#define FONT_NUM_START (27 + FONT_MEMORY_START)
#define FONT_EXTRA (36 + FONT_MEMORY_START)
#define FONT_BLANK (0 + FONT_MEMORY_START)
#define FONT_BLANK (FONT_MEMORY_START)


void setup_font(void);
Expand Down
26 changes: 10 additions & 16 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
#include "screens.c"
#include "font.c"
#include "board.c"
#include "sounds.c"


/**
* @brief Initialize GB settings and show title screen
*
*/
void setup(){
enable_sound();
SHOW_BKG;
SHOW_WIN;
SHOW_SPRITES;
Expand All @@ -24,47 +22,43 @@ void setup(){


void main() {
UINT8 button_pressed = 0;
UINT8 btn = 0;

setup();

while (1) {
button_pressed = joypad();
btn = waitpad(J_A | J_B | J_UP | J_DOWN | J_LEFT | J_RIGHT | J_START);
waitpadup();

switch (state){
case TITLE:
seed_rand();
if(button_pressed & J_START) {
if(btn == J_START) {
show_play_screen();
}
break;

case PLAYING:
if(button_pressed & J_UP){
if(btn == J_UP){
update_board(UP);
}else if(button_pressed & J_DOWN){
}else if(btn == J_DOWN){
update_board(DOWN);
}else if(button_pressed & J_RIGHT){
}else if(btn == J_RIGHT){
update_board(RIGHT);
}else if(button_pressed & J_LEFT){
}else if(btn == J_LEFT){
update_board(LEFT);
}else if(button_pressed & J_SELECT){
show_win_screen();
}

if(button_pressed){
delay(BUTTON_DELAY);
}
break;

case WINNER:
if(button_pressed & J_START){
if(btn == J_START){
show_title_screen();
}
break;

case GAMEOVER:
if(button_pressed & J_START){
if(btn == J_START){
show_title_screen();
}
break;
Expand Down
13 changes: 0 additions & 13 deletions src/sounds.c

This file was deleted.

8 changes: 0 additions & 8 deletions src/sounds.h

This file was deleted.

0 comments on commit 3a30bc5

Please sign in to comment.