User Tools

Site Tools


notes:comporg:spring2024:projects:cta0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:comporg:spring2024:projects:cta0 [2024/03/04 16:06] – [Collision With Food] wgates1notes:comporg:spring2024:projects:cta0 [2024/03/04 16:12] (current) – [Collision With Food] wgates1
Line 74: Line 74:
  
 From the code snip above, we first store our X and Y values in temp registers that will get destroyed later on. Then we calculated the difference. It does not matter if the result is negative or positive because we take the abs value. We take the absolute value because the difference in position is a difference. It's hard to explain but it just needs to be the abs value (Someone please step in and make this clearer. I cannot figure out how to say it).  From the code snip above, we first store our X and Y values in temp registers that will get destroyed later on. Then we calculated the difference. It does not matter if the result is negative or positive because we take the abs value. We take the absolute value because the difference in position is a difference. It's hard to explain but it just needs to be the abs value (Someone please step in and make this clearer. I cannot figure out how to say it). 
 +
 +Next, we want to check if the snake head comes in contact with the food. Here is what that looks like:
 +<code asm>
 +    ; Check if within 30 pixels
 +    ile R10, 30
 +    jf R10, _no_collision ; If false then go to _no_collision
 +
 +    ; Check if within 48 pixels
 +    ile R11, 48
 +    jf R11, _no_collision ; If false then go to _no_collision
 +</code>
 +
 +Here, we are simply just checking the difference we got for the X and Y values and then either jumping out of this check because they are not in contact or falling through to what will happen if we are in contact with the food. 
 ====Text Area==== ====Text Area====
  
notes/comporg/spring2024/projects/cta0.1709568414.txt.gz · Last modified: 2024/03/04 16:06 by wgates1