Skip to content

Commit

Permalink
Added death
Browse files Browse the repository at this point in the history
  • Loading branch information
IridescentRose committed Oct 6, 2020
1 parent 8d816b2 commit d785e0e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const psp = @import("Zig-PSP/src/psp/utils/psp.zig");
const gfx = @import("gfx.zig");
usingnamespace @import("Zig-PSP/src/psp/include/psprtc.zig");
usingnamespace @import("Zig-PSP/src/psp/include/pspdisplay.zig");
usingnamespace @import("Zig-PSP/src/psp/include/psploadexec.zig");

var current_time : u64 = 0;
var tickRate : u32 = 0;
Expand Down Expand Up @@ -446,6 +447,16 @@ fn bottomCollided() bool{
return false;
}

fn topCollided() bool{
var i : usize = 0;
while(i < activePiece.count) : (i += 1){
if(activePiece.block[i].y + activePiece.y >= 20){
return true;
}
}
return false;
}

fn addPieceToBoard() void {
var i : usize = 0;
while(i < activePiece.count) : (i += 1){
Expand Down Expand Up @@ -527,8 +538,12 @@ pub fn main() !void {

if(bottomCollided()){
activePiece.y += 1;
addPieceToBoard();
newPiece();
if(topCollided()){
sceKernelExitGame();
}else{
addPieceToBoard();
newPiece();
}
}

checkRows();
Expand Down

0 comments on commit d785e0e

Please sign in to comment.