Brace yourself for something VERY exciting...
Just a continuation from this post...
Mouse for player 2, arrow keys for player 1...
Add a bit more to it and post your code!
Graphics 640,480
MoveMouse 320,240
SetBuffer BackBuffer()
; keyboard controls
Const KUp=200
Const KDown=208
Const KLeft=203
Const KRight=205
; position and speed
xs#=0
ys#=0
x#=320
y#=240
b1#=0
b2#=0
bx1#=0
bx2#=0
; acceleration and friction
accel#=.2
friction#=.99
gravity#=.1
xs=Rnd(-5,5)
ys=Rnd(-5,-10)
Repeat
Cls
If KeyDown(kright) Then bx1=bx1+1
If KeyDown(kleft) Then bx1=bx1-1
; apply friction
xs=xs*friction
ys=ys*friction+gravity
bx1=bx1*.8
; add resultant speed to x and y positions
x=x+xs
y=y+ys
b1=b1+bx1
; bounce off sides
If x>639 Then x=639:xs=-xs
If x<0 Then x=0:xs=-xs
If y>479 Then y=479:ys=-ys
If y<0 Then y=0:ys=0
Oval x-6,y-6,12,12,True
b2=MouseX()-160
If b1>300 Then b1=300
If b1<20 Then b1=20
If b2>300 Then b2=300
If b2<20 Then b2=20
;bat 1
Rect b1-20,450,40,10,True
;bat 2
Rect b2-20+320,450,40,10,True
;net
Rect 320-4,480-200,8,200,True
If RectsOverlap(x-6,y-6,12,12,b1-20,450,40,10)
ys=-(ys*2)
xs=xs+Float(x-b1)/2
EndIf
If RectsOverlap(x-6,y-6,12,12,b2-20+320,450,40,10)
ys=-(ys*2)
xs=xs+Float(x-b2-320)/2
EndIf
If RectsOverlap(x-6,y-6,12,12,320-4,480-200,8,200)
xs=-xs
EndIf
Flip
Until KeyHit(1)
|