Hi!!
I'm working in a Snake like game in 2D... This is my first game in Blitz and I'm learning the language...
I have
Type worm
Field X, Y, H, W
end type
and the same for Walls, and food
now.. the localization for the walls is readed from Data wich have Level, #of walls, #of food, and the coods for each wall
thats ok, and works fine... I can draw each wall without problem, but the problem is that in the food the X, Y cords are Random and sometimes the food is behind the walls... then I use this:
For I = 1 To TotalC ;which is the total of food
F.Food = New Food ;Create a Food
Repeat
Ok = False
XF = Rnd(530) ;X cord of the food
YF = Rnd(470) ;Y Cord of the food
HF = 10 ;constant
WF = 10 ;Constant
For W.Wall = Each Wall ;all wall coords are here
XW = W\X ;X coord of wall
YW = W\Y ;Y coord of wall
HW = W\A ;Height of wall
WW = W\G ;Width coord of wall
If RectsOverlap(XF,YF,HF,WF,XP,YP,AP,GP) Then
OK = False
else
OK = True
End If
Next
Until OK = True
F\X = XF ; new coord without wall
F\Y = YF
Next
But the problem is that the food still behind the wall...
and really I don't know why
Can you help me???
Thanks
Bruno Chavez
I'm working in a Snake like game in 2D... This is my first game in Blitz and I'm learning the language...
I have
Type worm
Field X, Y, H, W
end type
and the same for Walls, and food
now.. the localization for the walls is readed from Data wich have Level, #of walls, #of food, and the coods for each wall
thats ok, and works fine... I can draw each wall without problem, but the problem is that in the food the X, Y cords are Random and sometimes the food is behind the walls... then I use this:
For I = 1 To TotalC ;which is the total of food
F.Food = New Food ;Create a Food
Repeat
Ok = False
XF = Rnd(530) ;X cord of the food
YF = Rnd(470) ;Y Cord of the food
HF = 10 ;constant
WF = 10 ;Constant
For W.Wall = Each Wall ;all wall coords are here
XW = W\X ;X coord of wall
YW = W\Y ;Y coord of wall
HW = W\A ;Height of wall
WW = W\G ;Width coord of wall
If RectsOverlap(XF,YF,HF,WF,XP,YP,AP,GP) Then
OK = False
else
OK = True
End If
Next
Until OK = True
F\X = XF ; new coord without wall
F\Y = YF
Next
But the problem is that the food still behind the wall...
and really I don't know why
Can you help me???
Thanks
Bruno Chavez