hiya all,
I have create some block on the screen but it showing just 1 block instead of 30 blocks on the screen
here the code
[BOX]
AppTitle "BLOCKOUT VERSION 0.1 "
Const ESCAPE=1
Type BALL
Field X,Y,DX,DY
End Type
Global BALLOCK.BALL = New BALL
Type BLOCK
Field X,Y
End Type
Graphics 640,480,16,2
SetBuffer BackBuffer()
HidePointer
; Loading Image
Global BLOCK=LoadAnimImage("Block.png",30,10,0,2)
Global BAT =LoadImage("BAT.png")
Global BALL =LoadImage("BALL.png")
Global BAT_X
Global BAT_Y
Global T
; Image Mask
MaskImage BLOCK,255,0,255
MaskImage BALL ,255,0,255
MaskImage BAT ,255,0,255
; Position the player
BAT_X = 320
BAT_Y = 440
; ball
BALLOCK\x = 342
BALLOCK\y = 428
; ball Speed
BALLOCK\DX = 2
BALLOCK\DY = 2
Restore DATA_BLOCK
For I=1 To 10
For J=1 To 3
Read DATA_BLOCK
BALLOCK2.BLOCK = New BLOCK
If DATA_BLOCK=0 Then Data_BLOCK=0
If DATA_BLOCK=1 Then Data_BLOCK=1
; If DATA_BLOCK=2 Then Data_BLOCK=2
tempX=BALLOCK2\X+I*55
tempY=BALLOCK2\Y+J*60
Next
Next
While Not KeyDown (ESCAPE)
For BALLOCK2.BLOCK = Each BLOCK
DrawImage Block,BALLOCK2\X,BALLOCK2\X+J*60,DATA_BLOCK
Next
CONTROL_PLAYER
COLISION
RENDER
Flip:Cls
Wend
.DATA_BLOCK
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
;Data 2,2,2,2,2,2,2,2,2,2
Function CONTROL_PLAYER()
If KeyDown(203) Then BAT_X=BAT_X-3
If KeyDown(205) Then BAT_X=BAT_X+3
If KeyDown(57)
T=True
EndIf
End Function
Function COLISION()
If T=True
; BALL MOVEMENT
BALLOCK\X=BALLOCK\X+BALLOCK\DX
BALLOCK\Y=BALLOCK\Y+BALLOCK\DY
; @#!*IN COLISION
If BALLOCK\X<=0 Or BALLOCK\X>=600 Then BALLOCK\DX=-BALLOCK\DX
If BALLOCK\Y<=0 Then BALLOCK\DY=-BALLOCK\DY
If BALLOCK\Y>=470 Then BALLOCK\DY=-BALLOCK\DY
; does it hit the BAT then send it home run
If ImagesOverlap(BAT,BAT_X,BAT_Y,BALL,BALLOCK\x,BALLOCK\Y)
BALLOCK\DY=-BALLOCK\DY
EndIf
; Does it hit the Block then Delete them
If ImagesOverlap(BALL,BALLOCK\x,BALLOCK\Y,Block,Block_X+I*55,J*60)
;Delete BALLOCK2 <<< PROBLEM
EndIf
Else
If KeyDown(203) Then BALLOCK\DY=-BALLOCK\DY: BALLOCK\x=BALLOCK\x-3
If KeyDown(205) Then BALLOCK\DY=-BALLOCK\DY:: BALLOCK\x=BALLOCK\x+3
; Stop the Ball moving off the Screen
If BALLOCK\x=<24 Then BALLOCK\x=24
If BALLOCK\x=>608 Then BALLOCK\x=608
EndIf
; STOP THE BAT RUNNING OUT OF PLAYING AREA
If BAT_X<=0 Then BAT_X=0
If BAT_X>585 Then BAT_X=585
End Function
Function RENDER()
DrawImage BALL,BALLOCK\x,BALLOCK\Y
DrawImage BAT,BAT_X,BAT_Y
End Function
[/BOX]
Can anyone point out what I am doing wrong?
cheers
I have create some block on the screen but it showing just 1 block instead of 30 blocks on the screen
here the code
[BOX]
AppTitle "BLOCKOUT VERSION 0.1 "
Const ESCAPE=1
Type BALL
Field X,Y,DX,DY
End Type
Global BALLOCK.BALL = New BALL
Type BLOCK
Field X,Y
End Type
Graphics 640,480,16,2
SetBuffer BackBuffer()
HidePointer
; Loading Image
Global BLOCK=LoadAnimImage("Block.png",30,10,0,2)
Global BAT =LoadImage("BAT.png")
Global BALL =LoadImage("BALL.png")
Global BAT_X
Global BAT_Y
Global T
; Image Mask
MaskImage BLOCK,255,0,255
MaskImage BALL ,255,0,255
MaskImage BAT ,255,0,255
; Position the player
BAT_X = 320
BAT_Y = 440
; ball
BALLOCK\x = 342
BALLOCK\y = 428
; ball Speed
BALLOCK\DX = 2
BALLOCK\DY = 2
Restore DATA_BLOCK
For I=1 To 10
For J=1 To 3
Read DATA_BLOCK
BALLOCK2.BLOCK = New BLOCK
If DATA_BLOCK=0 Then Data_BLOCK=0
If DATA_BLOCK=1 Then Data_BLOCK=1
; If DATA_BLOCK=2 Then Data_BLOCK=2
tempX=BALLOCK2\X+I*55
tempY=BALLOCK2\Y+J*60
Next
Next
While Not KeyDown (ESCAPE)
For BALLOCK2.BLOCK = Each BLOCK
DrawImage Block,BALLOCK2\X,BALLOCK2\X+J*60,DATA_BLOCK
Next
CONTROL_PLAYER
COLISION
RENDER
Flip:Cls
Wend
.DATA_BLOCK
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
;Data 2,2,2,2,2,2,2,2,2,2
Function CONTROL_PLAYER()
If KeyDown(203) Then BAT_X=BAT_X-3
If KeyDown(205) Then BAT_X=BAT_X+3
If KeyDown(57)
T=True
EndIf
End Function
Function COLISION()
If T=True
; BALL MOVEMENT
BALLOCK\X=BALLOCK\X+BALLOCK\DX
BALLOCK\Y=BALLOCK\Y+BALLOCK\DY
; @#!*IN COLISION
If BALLOCK\X<=0 Or BALLOCK\X>=600 Then BALLOCK\DX=-BALLOCK\DX
If BALLOCK\Y<=0 Then BALLOCK\DY=-BALLOCK\DY
If BALLOCK\Y>=470 Then BALLOCK\DY=-BALLOCK\DY
; does it hit the BAT then send it home run
If ImagesOverlap(BAT,BAT_X,BAT_Y,BALL,BALLOCK\x,BALLOCK\Y)
BALLOCK\DY=-BALLOCK\DY
EndIf
; Does it hit the Block then Delete them
If ImagesOverlap(BALL,BALLOCK\x,BALLOCK\Y,Block,Block_X+I*55,J*60)
;Delete BALLOCK2 <<< PROBLEM
EndIf
Else
If KeyDown(203) Then BALLOCK\DY=-BALLOCK\DY: BALLOCK\x=BALLOCK\x-3
If KeyDown(205) Then BALLOCK\DY=-BALLOCK\DY:: BALLOCK\x=BALLOCK\x+3
; Stop the Ball moving off the Screen
If BALLOCK\x=<24 Then BALLOCK\x=24
If BALLOCK\x=>608 Then BALLOCK\x=608
EndIf
; STOP THE BAT RUNNING OUT OF PLAYING AREA
If BAT_X<=0 Then BAT_X=0
If BAT_X>585 Then BAT_X=585
End Function
Function RENDER()
DrawImage BALL,BALLOCK\x,BALLOCK\Y
DrawImage BAT,BAT_X,BAT_Y
End Function
[/BOX]
Can anyone point out what I am doing wrong?
cheers