diff --git a/artwork/shapes.asm b/artwork/shapes.asm index ea3f1b4..b5542f8 100644 --- a/artwork/shapes.asm +++ b/artwork/shapes.asm @@ -79,5 +79,10 @@ ShapesTableH .by >bird_1 .by >bird_2 .by >cactus_0 +diff_object_gap ; min distance between obstacles by difficulty level + :16 .by 20-# +;----------vars---------- +diff_level .ds 1 + .endif ; .IF *>0 diff --git a/dino.asm b/dino.asm index 89388d4..b223d86 100644 --- a/dino.asm +++ b/dino.asm @@ -1,4 +1,5 @@ SCR_HEIGHT = 8 +WORLD_LENGTH = 64 ; No internet ;--------------------------------------------------- @@ -53,11 +54,13 @@ line:1_addr ;--------------------------------------------------- ; World table without dino WorldTable - :64 .byte 0 ; ground + :WORLD_LENGTH .byte 0 ; ground ;--------------------------------------------------- FirstSTART jsr GenerateCharsets jsr ClearWorld + mva #0 diff_level + ; test only (some object in the world) lda #1 ;bird0 sta WorldTable+10 @@ -140,7 +143,7 @@ CopyLoop .endp ;----------------------------------------------- .proc ClearWorld - ldy #63 ; world size + ldy #WORLD_LENGTH-1 ; world size lda #0 ; ground @ sta WorldTable,y dey @@ -148,7 +151,7 @@ CopyLoop rts .endp .proc ClearScreen - ldy #64 + ldy #WORLD_LENGTH ; TODO: shouldn't be -1? lda #0 ClearLoop sta screen+$700,y @@ -173,7 +176,7 @@ ToScreenLoop NothingToDraw inc temp_b ldx temp_b - cpx #64 + cpx #WORLD_LENGTH bne ToScreenLoop rts .endp @@ -184,12 +187,35 @@ Shift lda WorldTable+1,y sta WorldTable,y iny - cpy #63 + cpy #WORLD_LENGTH-1 bne Shift lda #0 ;ground sta WorldTable,y ; now we can insert random object to world end + ; check if there is enough of the gap between obstacles + + ; get the gap for the given difficulty level + ldx diff_level + lda #WORLD_LENGTH + sec + sbc diff_object_gap,x + tax + + ; is there a gap? +@ + lda WorldTable,x + bne noInsert + inx + cpx #WORLD_LENGTH + bne @- + ;all zeroes +insertObject + mva #1 WorldTable+WORLD_LENGTH-2 + + + +noInsert rts .endp ;----------------------------------------------- diff --git a/dino.xex b/dino.xex index 35c9f43..5ad4253 100644 Binary files a/dino.xex and b/dino.xex differ