Wow, it’s finally out! It’s small.


Grading rubric


0. Stuff to download and getting started

Download this file and extract it somewhere sensible. Then rename the abc123_proj1.asm file appropriately.

Overview:

and of course, _proj1.asm is the program itself.

If you assemble and run right now, you’ll see this:

It’s….. a big empty concrete floor! With some numbers in the bottom corners. Huh.


1. Updating load_map

If you successfully wrote load_map on lab 3, great! This will be easy.

If you didn’t get to load_map on lab 3, or didn’t finish it successfully, go back and do it. I’m serious. You’re not gonna understand what I’m talking about until you do. (Note that load_map in lab 3 requires place_tile to work properly. Oh look at that, there’s an implementation of place_tile in this project! How nice of me)

Okay, so, your project 1 load_map is gonna be very similar to the one from lab 3, with the following differences:

Then, char_to_tile_type needs to be changed so it works like so:

Also, it seemed to escape a lot of people on lab 3 that you can just write e.g. li v0, TILE_WHATEVER to return a constant

go go go make those changes

your goal is to see this:

woo nice!


2. Extending load_map to include objects

The map data also has some characters that represent objects, which are new for the project. Here’s how you do it:

  1. make a char_to_obj_type function which takes a character and maps it to an OBJ_ constant, very much like char_to_tile_type. It works like:
    • '$' returns OBJ_PLAYER
    • 'o' returns OBJ_PUMPKIN
    • any other character returns OBJ_EMPTY
  2. in load_map, after placing the tile, then pass the character into char_to_obj_type
    • if it doesn’t return OBJ_EMPTY:
      • do new_object((col * 8) + 4, (row * 8) + 4, v0)

Be careful about the ATV rule! Since you called char_to_tile_type, you cannot just reuse the character that was in a0 when calling char_to_obj_type. It’s up to you to solve that issue.

This is what you want to see:


Try it out!

The little yellow ball is you, the player. Click on the display and use the W, A, S, D keys to move the player around. Things to note:


3. Periodic events

Those goo tiles are the hazard in this little game. The light green goo is static, but the dark green goo grows. Or, it’s supposed to.

First, we need to make a periodic event. We don’t want the goo to grow on every single frame. If it did that, it would fill the entire map in about 1 second. Instead, we’ll only update the goo about once per second by only doing it on some frames but not others.

We’ll do this by using the goo_timer variable (defined around line 21). Here’s how it works:

You’re going to implement that logic in the empty update_goo_if_needed function.

Then in the empty update_goo function, put print_str "update! ".

When you run, you should see the word “update!” printed in the console about once per second.

If it’s printing many many times per second, something is wrong. Most likely, you wrote the if-else wrong. Don’t forget the jump over the else.


4. Making the goo grow

The basic algorithm for making the goo grow is pretty simple. It’s something like this:

  1. Call copy_tm_to_prev_tm.
    • This makes a backup copy of the tilemap (display_tm_table) into prev_tm.
  2. For each tile in the tilemap,
    • if this tile was a goo edge tile previously (i.e. in prev_tm),
      • if the tile above was empty previously, make it a goo edge.
      • if the tile below was empty previously, make it a goo edge.
      • if the tile to the left was empty previously, make it a goo edge.
      • if the tile to the right was empty previously, make it a goo edge.
      • make this tile a goo tile (instead of a goo edge)

Here are some tips to approach this:


5. Making the goo grow, but slower and more organically

Now the goo grows, but it’s kind of fast. It’s also very… geometric. But it’s goo!! Goo is organic!!! I guess idk lol it’s halloween-y

Fortunately, fixing this is pretty easy.

In update_goo, right after you check if this tile is goo, but before you check the tiles around it, you’re gonna insert some code:

that’s it. Now when you run it, the goo should expand slower, and randomly, making it different every time. For example:

If it still grows fast, even if it’s random, you inverted the condition. Like, this is too fast:


Try it out

Once you’re sure it’s working right, look around line 85 in main. You’ll see this:

    la  a0, test_level
    #la  a0, level_1
    jal load_map

Comment out the la a0, test_level and uncomment the la a0, level_1. Now (assuming you wrote load_map right!) you should see a different level when you run:

See if you can get to the exit!

There is also a line at the top of your project like .eqv INVULNERABILITY 0. Change that 0 to a 1, and now you cannot be hurt by the goo. Cheater!

Last, if you uncomment the lines with ################### EDITOR ################### on them, you have access to a very simple level editor in-game. 1, 2, 3, 4 choose which tile to place; click to place tiles; P to print out a representation of the map to the console. It doesn’t print object locations though, so you’ll have to add those yourself by putting $ and o in the righe places.


Yep that’s it, submitting

There’ll be a gradescope open like tomorrow, I’m tired okay