I am playing with a few ideas, mainly to test collisions on bitmaps.
I have a program that has four sprites running across the screen in various directions. What I did is to change the mouse pointer to a VERY simply crosshair and then looking for collisions.
When I shoot the first bitmap, it disapears off the screen (in a very dirty way). But then it never detects any after that.
Where am I going wrong?
Code:
Graphics3D 1024,768,32
SetBuffer BackBuffer()
Global font
Global backgr
Global lemm1,lemm2,lemm3,lemm4
Global lemm1h,lemm2h,lemm3h,lemm4h
Global lemmimage
Global l1x,l1y, l2x, l2y, l3x, l3y, l4x, l4y
Global cross
font=LoadFont("Arial",12,False,False,False)
SetFont font
;backgr=LoadImage("")
lemmimage=LoadImage("lemm.png")
cross=LoadImage("cross.png")
lemm1=lemmimage
lemm2=lemmimage
lemm3=lemmimage
lemm4=lemmimage
mainloop()
Function mainloop()
While Not KeyHit(1)
;DrawImage backgr,0,0
Cls
DrawImage lemm1,l1x,l1y
DrawImage lemm2,l2x,l2y
DrawImage lemm3,l3x,l3y
DrawImage lemm4,l4x,l4y
DrawImage cross,MouseX(),MouseY()
;movement (levels)
l1x=l1x+1:l1y=l1y+2
l2x=l2x+4:l2=l2y+1
l3x=l3x+2:l3y=l3y+3
l4x=l4x+1l4y=l4y+0
;collision detection
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm1,l1x,l1y,0) And MouseHit(1) Then l1x=10000
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm2,l2x,l2y,0) And MouseHit(1) Then l2x=10000
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm3,l3x,l3y,0) And MouseHit(1) Then l3x=10000
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm4,l4x,l4y,0) And MouseHit(1) Then l4x=10000
Flip
Wend
End Function
I have a program that has four sprites running across the screen in various directions. What I did is to change the mouse pointer to a VERY simply crosshair and then looking for collisions.
When I shoot the first bitmap, it disapears off the screen (in a very dirty way). But then it never detects any after that.
Where am I going wrong?
Code:
Graphics3D 1024,768,32
SetBuffer BackBuffer()
Global font
Global backgr
Global lemm1,lemm2,lemm3,lemm4
Global lemm1h,lemm2h,lemm3h,lemm4h
Global lemmimage
Global l1x,l1y, l2x, l2y, l3x, l3y, l4x, l4y
Global cross
font=LoadFont("Arial",12,False,False,False)
SetFont font
;backgr=LoadImage("")
lemmimage=LoadImage("lemm.png")
cross=LoadImage("cross.png")
lemm1=lemmimage
lemm2=lemmimage
lemm3=lemmimage
lemm4=lemmimage
mainloop()
Function mainloop()
While Not KeyHit(1)
;DrawImage backgr,0,0
Cls
DrawImage lemm1,l1x,l1y
DrawImage lemm2,l2x,l2y
DrawImage lemm3,l3x,l3y
DrawImage lemm4,l4x,l4y
DrawImage cross,MouseX(),MouseY()
;movement (levels)
l1x=l1x+1:l1y=l1y+2
l2x=l2x+4:l2=l2y+1
l3x=l3x+2:l3y=l3y+3
l4x=l4x+1l4y=l4y+0
;collision detection
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm1,l1x,l1y,0) And MouseHit(1) Then l1x=10000
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm2,l2x,l2y,0) And MouseHit(1) Then l2x=10000
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm3,l3x,l3y,0) And MouseHit(1) Then l3x=10000
If ImagesCollide (cross,MouseX(),MouseY(),0,lemm4,l4x,l4y,0) And MouseHit(1) Then l4x=10000
Flip
Wend
End Function