GithubHelp home page GithubHelp logo

nandspaceinvaders's Introduction

NandSpaceInvaders

A simple space invaders game written in Jack for Nand2Tetris Part II

Table of Contents

Setup/Running

  • Clone the repo to a folder named NandSpaceInvaders
  • Compile the entire folder to VM code using the Nand2Tetris Jack Compiler
  • Run the Nand2Tetris VM Emulator
  • Open the compiled folder in the VM Emulator, running it with Animate set to "No animation"

Controls

  • โ† Move Tank Left
  • โ†’ Move Tank Right
  • Space Fire bullet

Ending the Game

There is no real "winning" mechanism. The game will keep track of how many invaders you destroy and will end when any 1 invader successfully lands. It will then output a "GAME OVER" message as well as the count of destroyed invaders.

Additional Notes

There are some additional classes and methods I used for testing/development such as Logger and anything named with the prefix Test. These were really helpful for the dev process, but are not particularly necessary unless you wanted to continue development on this.

I've also made some design/logic decisions that are probably not best practice. One such example is having my LinkedList add method always add at index 1 instead of at index 0 or the end of the list. It was honestly just easier/faster to implement it that way.

Another example is that I've created both BulletList and InvaderList and there is a lot of repeat code between them. There probably is a way to have made it a generic LinkedList instead, but I chose not to pursue that for 2 main reasons:

  1. The purpose of this program was not really to become an expert in the Jack programming language. The course states that this project's purpose is to help us familiarize ourselves with the Jack language since we'll be building a compiler for it later.
  2. The game works as-is; I did not want to "waste" a lot of time trying to perfect something that I will likely never use again.

To build on point 2, there also may be a bug or 2 in how we process collisions between bullets and invaders. For one, the rendering is not pixel-perfect so some collisions appear as if they're incorrect when from a coordinate perspective they are actually correct. Because the sprites are built in a 16x16 grid, they don't always 100% align horizontally.

Here's the formula we use to determine at which memory address to start drawing a sprite:

$$32 * y + x / 16$$

Because of this formula, combined with the sprites being 16x16, sprite drawing horizontally tends to jump every 16 pixels, rather than moving 1 pixel at a time. From a gameplay perspective, it is mostly unnoticeable, but can be seen pretty evidently in that bullets are always equally spaced:

Gameplay Image

All-in-all, was a fun project.

License

Licensed under MIT.

nandspaceinvaders's People

Contributors

zacharyeller13 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.