Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunakw committed Apr 2, 2023
0 parents commit 3283130
Show file tree
Hide file tree
Showing 45 changed files with 8,665 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.o
*.elf
*.gba
*.sav
*.log
submission.tar.gz
!examples/**
Binary file added HW08.pdf
Binary file not shown.
91 changes: 91 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
################################################################################
# These are variables for the GBA toolchain build
# You can add others if you wish to
# ***** YOUR NAME HERE *****
################################################################################

# TA-TODO: Put your application name here.
# This should be a just a name i.e MyFirstGBAProgram
# No SPACES AFTER THE NAME.
PROGNAME = App

# TA-TODO: Add the C files you want compiled here (replace extension with .o)
# Here you must put a list of all of the object files
# that will be compiled into your program. For example
# if you have main.c and myLib.c then in the following
# line you would put main.o and myLib.o
OFILES = gba.o font.o main.o lib.o images/bg.o images/dead.o images/tank_blue.o images/tank_red.o images/heart_blue.o images/heart_red.o images/bullet_blue.o images/bullet_red.o images/ammo_blue.o images/ammo_red.o

################################################################################
# These are various settings used to make the GBA toolchain work
# DO NOT EDIT BELOW.
################################################################################

.PHONY: all
all: CFLAGS += $(CRELEASE) -I../shared
all: LDFLAGS += $(LDRELEASE)
all: $(PROGNAME).gba
@echo "[FINISH] Created $(PROGNAME).gba"

include /opt/cs2110-tools/GBAVariables.mak

LDFLAGS += --specs=nosys.specs

# Adjust default compiler warnings and errors
CFLAGS += -Wstrict-prototypes -Wold-style-definition -Werror=vla

.PHONY: debug
debug: CFLAGS += $(CDEBUG) -I../shared
debug: LDFLAGS += $(LDDEBUG)
debug: $(PROGNAME).gba
@echo "[FINISH] Created $(PROGNAME).gba"

$(PROGNAME).gba: $(PROGNAME).elf
@echo "[LINK] Linking objects together to create $(PROGNAME).gba"
@$(OBJCOPY) -O binary $(PROGNAME).elf $(PROGNAME).gba

$(PROGNAME).elf: crt0.o $(GCCLIB)/crtbegin.o $(GCCLIB)/crtend.o $(GCCLIB)/crti.o $(GCCLIB)/crtn.o $(OFILES) libc_sbrk.o
$(CC) -o $(PROGNAME).elf $^ $(LDFLAGS)

.PHONY: release
release: CFLAGS += $(CRELEASE) -I../shared
release: LDFLAGS += $(LDRELEASE)
release: $(PROGNAME).gba
@echo "Built $(PROGNAME).gba with release flags"

.PHONY: mgba
mgba: debug
@echo "[EXECUTE] Running emulator mGBA"
@echo " Please see emulator.log if this fails"
@mgba-qt $(PROGNAME).gba

.PHONY: gdb
gdb: debug
@echo "[EXECUTE] Running Emulator MGBA with GDB"
@echo " Please see emulator.log if this fails"
@mgba-qt $(PROGNAME).gba --gdb &
# To give mgba some time to initialize and start up the GDB server.
@sleep 0.5
@gdb-multiarch -ex 'file $(PROGNAME).elf' -ex 'target remote 127.0.0.1:2345'

.PHONY: submit
submit: clean
@rm -f submission.tar.gz
@tar --exclude="examples" -czvf submission.tar.gz *

.PHONY: maze
maze:
@echo "[EXECUTE] Running emulator mGBA"
@echo " Please see emulator.log if this fails"
@mgba-qt examples/maze/Maze.gba

.PHONY: mario
mario:
@echo "[EXECUTE] Running emulator mGBA"
@echo " Please see emulator.log if this fails"
@mgba-qt examples/mario/Mario.gba

.PHONY: clean
clean:
@echo "[CLEAN] Removing all compiled files"
rm -f *.o *.elf *.gba *.log */*.o *.sav */*/*.sav
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Tank Battle

## Objective

### 1-Player mode

Move your tank in two dimensions while trying to avoid the bullets raining from the sky. Try to last as long as possible without losing all of your lives.

### 2-Player mode

Face off against a friend in a tank vs. tank battle. Each player has 3 ammo slots and will reload automatically. Try to destroy your opponent's health before they destroy yours.

## Controls

The start screens for each mode will also display the controls for that mode.

### Mode select

| Action | Control (keyboard) |
| ------------- | ------------------ |
| 1-Player mode | A |
| 2-Player mode | S |

### Start (mode selected)

| Action | Control (keyboard) |
| ------ | ------------------ |
| Start | Enter |
| Back | S |

### 1-Player mode

| Action | Control (keyboard) |
| ------ | ------------------ |
| Left | Left arrow |
| Right | Right arrow |
| Up | Up arrow |
| Down | Down arrow |

### 2-Player mode

| Action | Blue Control (keyboard) | Red Control (keyboard) |
| ------ | ----------------------- | ---------------------- |
| Left | Z | Left arrow |
| Right | X | Right arrow |
| Up | S | Up arrow |

## Images

The two fullscreen images are in the start screen and the 1-player death screen.

Various non-fullscreen images appear in 1-player and 2-player modes.
Binary file added examples/mario/Mario.gba
Binary file not shown.
18 changes: 18 additions & 0 deletions examples/mario/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Rescue Princess Peach

How the game works:
- This purpose of this game is for the player (mario) to reach princess peach.
- If mario collides with a goomba, the player loses.
- Additionally, the player's score decreases over time.
- If the score reaches 0, the player loses.
- If mario colides with princess peach, the player wins.

How to play:
- Click enter to start the game from the welcome screen
- use the arrows to move mario in any direction
- Click backspace to restart the game at any time

To run this game:
- download the zip file
- navigate into folder hw08 in terminal in docker
- run command -> make mgba
Binary file added examples/maze/Maze.gba
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/maze/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
On the title screen, the program will transition to the maze screen after pressing 'START'.

On the maze screen, the program will display a maze with a small blue square in the bottom left corner, which acts as the player. The player cannot go through the maze walls and can move in all four directions using the arrow keys.

In the bottom right corner, there is a large green box, and the player has 60 seconds to reach the green box to win. There is also a wall that blocks the player from reaching the green box and makes the maze seem "impossible". The only purpose is just to mess with people and can simply be removed by pressing the 'A' button.

There is also a red box in the top right corner that will cause the player to lose when they comes into contact with it.

While on the maze screen, the 'SELECT' button can be pressed to bring the program back to the title screen and the program will continue as if it had been started for the first time.

The program will continue to the win screen if the player reaches the green box on the maze screen within the time limit. From the win screen, one can go back to the title screen by either pressing 'START' or 'SELECT'.

The program will continue to the lose screen if the player does not reach the green box within 60 seconds or if the player touches the red box. From this screen, one can go back to the title screen by either pressing 'START' or 'SELECT'.
Loading

0 comments on commit 3283130

Please sign in to comment.