Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Include Once "fbgfx.bi"
- Using fb
- ScreenRes(640,480,32)
- Declare Sub collision
- Declare Sub check_direction
- Dim As Integer point_stop
- Dim Shared As Integer x1,x2,y1,y2,r,r2
- Dim Shared As Integer col 'collide
- Dim game_point As Integer
- Dim samx As Integer
- Dim samy As Integer
- Dim samx1 As Integer
- Dim samy1 As Integer
- r = 20
- r2 = 10
- x1 = 200
- y1 = 200
- Sub collision
- Dim tempx As Integer
- Dim tempy As Integer
- Dim tempz As Integer
- tempx = (x2 - x1)*(x2 - x1)
- tempy = (y2 - y1)*(y2 - y1)
- tempz = tempx + tempy
- If Sqr(tempz) < r+r2 Then col = 1 Else col = 0
- End Sub
- Sub check_direction
- If x1 < x2 Then x1-=1 Else x1+=1
- If y1 < y2 Then y1-=1 Else y1+=1
- If x2 < x1 Then x2-=1 Else x2+=1
- If y2 < y1 Then y2-=1 Else y2+=1
- End Sub
- Do While Not MultiKey(SC_ESCAPE)
- samx = x1 'Have to put the location store before the movement otherwise the samx will always be equal to x1
- samy = y1
- samx1 = x2
- samy1 = y2
- If MultiKey(SC_W) Then y1 -= 2
- If MultiKey(SC_S) Then y1 += 2
- If MultiKey(SC_A) Then x1 -= 2
- If MultiKey(SC_D) Then x1 += 2
- If MultiKey(SC_UP) Then y2 -= 2
- If MultiKey(SC_DOWN) Then y2 += 2
- If MultiKey(SC_LEFT) Then x2 -= 2
- If MultiKey(SC_RIGHT) Then x2 += 2
- If MultiKey(SC_R) Then r-=1
- If MultiKey(SC_T) Then r+=1
- If MultiKey(SC_Y) Then r2-=1
- If MultiKey(SC_U) Then r2+=1
- collision
- If col = 1 And samx <> x1 Then x1 = samx 'compares old x value to new x value and nulls the movement
- If col = 1 And samy <> y1 Then y1 = samy 'Compares old y value to new y value and nulls the movement
- If col = 1 And samx1 <> x2 Then x2 = samx1 'same as above
- If col = 1 And samy1 <> y2 Then y2 = samy1 'same as above
- If col = 1 Then check_direction
- If col = 1 Then Circle(x1,y1),r,RGBA(255,0,0,10),,,,F Else Circle(x1,y1),r,RGBA(100,100,100,10),,,,F
- If col = 1 Then Circle(x2,y2),r2,RGBA(255,0,0,10),,,,F Else Circle(x2,y2),r2,RGBA(100,100,100,10),,,,F
- 'If col = 1 And point_stop = 0 And samx - Then game_point +=1
- 'If col = 1 Then point_stop = 1 Else point_stop = 0
- Print col
- Sleep 10
- Cls
- Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement