Anyway the reason I show this is because it's difficult for new programmers to understand how enemy logic works.
http://www.uploadmb.com/dw.php?id=1414491142
prg file
http://www.uploadmb.com/dw.php?id=1414491195
Source i'll comment here later tomorrow shouldn't be needed but i'll do it anyway
Code: Select all
.pc = $801
.byte $0b, $08, $06, $00, $9e, $32, $30, $36, $34, 0,0,0
.pc = $810
jmp Start
.var _ObjectDirection = $03
.const Black = 0
.const White = 1
.const Red = 2
.const Cyan = 3
.const Purple = 4
.const Green = 5
.const Blue = 5
.const Yellow = 7
.const Orange = 8
.const Brown = 9
.const Pink = 10
.const DarkGrey = 11
.const MediumGrey = 12
.const LightGreen = 13
.const LightBlue = 14
.const LightGrey = 15
.const ObjectFrameDataPointer = $07f8
.const ObjectColorReg = $d027
Start:
jsr Do_ClearScreen
lda #Black
sta $d020 //BorderColorReg = Black
sta $d021 //BackRoundColor Reg = Black
lda #%00000011 //Enable 2 objects
sta $d015
lda #Purple
sta ObjectColorReg
lda #Cyan
sta ObjectColorReg+1
ldx #$80
stx ObjectFrameDataPointer
stx ObjectFrameDataPointer+1
ldx #1
stx _ObjectDirection
dex
stx _ObjectDirection+1
lda #50
sta $d000 //Object 1 xposition
lda #240
sta $d002 //Object 2 x poosition
lda #100
sta $d001 //Object 1 y position
lda #160
sta $d003 //Object 2 y position
GameLoop:
jsr Do_HandleVblank
jsr Do_HandleObjects
jmp GameLoop
Do_HandleVblank:
lda $d012
bpl Do_HandleVblank
VblankWait:
lda $d012
bmi VblankWait
rts
////////////////////////////////////////////////////////////////////////////////
//Object Direction
//1 = east
//0 = west
////////////////////////////////////////////////////////////////////////////////
Do_HandleObjects:
ldy #1
ldx #2
HandleObjectsCont:
lda _ObjectDirection,y
beq ObjectDirectionWest
ObjectDirectionEast:
inc $d000,x
lda $d000,x
cmp #254
bne NextObject
InvertDirection:
lda _ObjectDirection,y
eor #1
sta _ObjectDirection,y
jmp NextObject
ObjectDirectionWest:
dec $d000,x
lda $d000,x
cmp #26
bne NextObject
jmp InvertDirection
NextObject:
dex
dex
dey
bpl HandleObjectsCont
rts
Do_ClearScreen:
ldx #0
lda #32
ClearScreenLoop:
sta $400,x
sta $500,x
sta $600,x
sta $700,x
inx
bne ClearScreenLoop
rts
.pc = $2000-2
.import binary "BoxObject.prg"