Beach VolleyBall Community project

Community Forums/Showcase/Beach VolleyBall Community project

Rob Farley(Posted 2004) [#1]
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)



Rob Farley(Posted 2004) [#2]
Well this was a resounding success!!

I thought this would be a bit of fun!


IPete2(Posted 2004) [#3]
Hee hee,

That's great stuff! I love the way it rebounds!

IPete2.


googlemesilly(Posted 2004) [#4]
me too, it's fun ! :)


Bot Builder(Posted 2004) [#5]
lol. All you need to do is replace the boxes with DOA chicks and add 'realistic physics' ;)

Also, if you hit the ball right on top, errors occur.

Other than that, pretty good :)


googlemesilly(Posted 2004) [#6]
lol