{"id":28974833,"url":"https://github.com/plcoster/ubc_htc1_space_invaders","last_synced_at":"2026-02-02T18:04:14.103Z","repository":{"id":299016115,"uuid":"597219905","full_name":"PLCoster/ubc_htc1_space_invaders","owner":"PLCoster","description":"Space Invaders Project for UBC How to Code Course","archived":false,"fork":false,"pushed_at":"2023-02-04T00:25:17.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-14T06:32:58.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PLCoster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-03T22:32:37.000Z","updated_at":"2023-02-04T00:19:19.000Z","dependencies_parsed_at":"2025-06-14T06:33:03.264Z","dependency_job_id":"3d4b5990-0f8e-41bd-8ee3-80709708bc34","html_url":"https://github.com/PLCoster/ubc_htc1_space_invaders","commit_stats":null,"previous_names":["plcoster/ubc_htc1_space_invaders"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PLCoster/ubc_htc1_space_invaders","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLCoster%2Fubc_htc1_space_invaders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLCoster%2Fubc_htc1_space_invaders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLCoster%2Fubc_htc1_space_invaders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLCoster%2Fubc_htc1_space_invaders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PLCoster","download_url":"https://codeload.github.com/PLCoster/ubc_htc1_space_invaders/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLCoster%2Fubc_htc1_space_invaders/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261669008,"owners_count":23192362,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-24T12:07:07.222Z","updated_at":"2026-02-02T18:04:14.037Z","avatar_url":"https://github.com/PLCoster.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UBC HtC1 - Functional Programming in BSL\n\n## Final Project - Space Invaders\n\nThe aim of this project was to build a 'Space Invaders' style game using [BSL](https://docs.racket-lang.org/htdp-langs/beginner.html) (a subset of [Racket](https://racket-lang.org/)), as a 'world' program utilising the `big-bang` function. The specification for the game can be seen below.\n\n![Image showing three states of gameplay in the space invader game. 1 - Game start with small black tank at bottom of screen and blue invaders floating down from the top of the screen. 2 - mid gameplay with the tank firing red missiles up at the invaders to destroy them. 3 - Game over screen where an invader has reached the bottom of the screen.](./space-invader.png)\n\n### How to Play\n\nThis program can be run using the [DrRacket](https://download.racket-lang.org/all-versions.html) IDE. After installing, open the project file `1-space-invaders.rkt` and then click the green 'Run' arrow in the IDE. This loads the game and runs all its tests. To then play the game, type the following in the DrRacket terminal:\n\n`\u003e (main (make-game empty empty T0))`\n\nThe objective of the game is to destroy the space ships that move down from the top of the screen, by shooting them with missiles from the player-controlled 'Tank' at the bottom. If a space ship reaches the bottom of the screen, you lose!\n\n#### Controls\n\n- `Left / Right Arrow Keys` - Change direction the player 'Tank' is moving in.\n- `Spacebar` - Fire a missile from the 'Tank'.\n\n### Program Details\n\nThe game runs using the `big-bang` function - this function 'ticks' 28 times per second, and on each tick can will call a series of other functions in order to:\n\n- update the game state (`on-tick`)\n- render the new game state to the screen (`to-draw`)\n- end the game state when appropriate (`stop-when`)\n- handle key presses to allow the player to control the game (`on-key`)\n\nThe game state (`Game` data definition) consists of a list of `Invader`, a list of `Missile` and a `Tank`.\n\n- `Tank` contains a Number `x` and an Integer[-1, 1] `dir`, its x-coordinate and the direction it is moving (-1 for moving left, 1 for moving right).\n- `Invader` contains three Numbers `x`, `y`, and `dx` - its x and y coords on the screen, and its velocity in the x-direction (negative meaning moving left).\n- `Missile` contains two Numbers `x` and `y`, the onscreen coordinates of the missile.\n\nOn each tick of the game, the `on-tick` function of `big-bang` calls `update-game` which performs the following steps:\n\n- Updates the list of `Invader` in the `Game` by:\n  - Removing any `Invader` that is colliding with a `Missile` (`destroy-invaders`)\n  - Moving the remaining `Invaders` according to their current `dx`, and bouncing them off any walls if they collide (`move-invaders`)\n  - Randomly spawning a new `Invader` at the top of the screen and adding it to the end of the list of `Invader` (`spawn-invaders`)\n- Updates the list of `Missile` in the `Game` by:\n  - Removing any `Missile` that is colliding with an `Invader`(`destroy-missiles`)\n  - Moving the remaining `Missiles` vertically up the screen, removing any that have already left the top of the screen (`move-missiles`).\n- Updates the `Tank` position according to its movement direction (`move-tank`)\n\nOnce the `Game` state is updated, the new scene is rendered by `to-draw` calling `render`, which renders the 'Tank`, then 'Missiles' and finally 'Invaders' onto the game background.\n\nThe `on-key` function calls `handle-key` to handle any user keyboard input, which:\n\n- checks if the left or right arrow key is pressed, and will update the tanks direction if so (`update-tank-direction`)\n- checks if the spacebar is pressed, and if so, spawns a new missile at the current `Tank` position (`add-missile`)\n\nOn each tick `stop-when` calls `game-over?` which checks if any `Invader` has reached the bottom of the screen, if this is the case then the game ends.\n\n### Specification\n\nThere are many different versions of Space Invaders. For this project, your Space Invaders game should have the following behaviour:\n\n- The tank should move right and left at the bottom of the screen when you press the arrow keys. If you press the left arrow key, it will continue to move left at a constant speed until you press the right arrow key.\n- The tank should fire missiles straight up from its current position when you press the space bar.\n- The invaders should appear randomly along the top of the screen and move at a 45 degree angle. When they hit a wall they will bounce off and continue at a 45 degree angle in the other direction.\n- When an invader reaches the bottom of the screen, the game is over.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplcoster%2Fubc_htc1_space_invaders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplcoster%2Fubc_htc1_space_invaders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplcoster%2Fubc_htc1_space_invaders/lists"}