GunZ Factor Forums

Go Back   GunZ Factor Forums > Community > Spam, Rants, Whatever

Become a Gold or Silver Member

Reply
 
Thread Tools
Old 07-26-2007, 12:02 PM   #1 (permalink)
Banned
 

Join Date: Jun 2007
Posts: 183
Poon King is a glorious beacon of light.Poon King is a glorious beacon of light.Poon King is a glorious beacon of light.

Default fgdfg

#Include "fbgfx.bi"
#Macro PageInit()
ScreenLock
#EndMacro
#Macro PageFlip()
ScreenUnLock
Screenlock
#EndMacro
#Macro PageClose()
Screenunlock
#EndMacro
#Define Container Do
#Define SetToTop Continue Do
#Define ExitContainer Exit Do
#Define EndContainer Loop While 0 > 1

Namespace Pong

'' The side the ball is paddle is on.
Enum Side
LSide = 0
RSide = 1
End Enum


'' a 2D vector.
Type Vect2D
X As Double
Y As Double
End Type


'' A paddle ball
Type Ball
Pos As vect2D
Vel As Vect2D

Rad As Double
Spd As Double
End Type


'' A paddle.
Type Paddle
Pos As Double
Size As Vect2D

Side As Integer
End Type

End Namespace


'' Main Code.

'' Set up our paddle and pall.
Dim As Pong.Paddle Paddle(1)
Dim As Pong.Ball Ball

'' Score.
Dim As Integer Score


'' Set up paddle sides.
Paddle(0).Side = Pong.LSide
Paddle(1).Side = Pong.RSide

'' Set up paddle sizes.
Paddle(0).Size = Type<Pong.Vect2D>( 5, 80 )
Paddle(1).Size = Type<Pong.Vect2D>( 5, 80 )


'' Set up the ball.
Ball.Pos = Type<Pong.Vect2D>( 319, 239 )

'' Set up a velocity.
Ball.Vel = Type<Pong.Vect2D>( -.5, -.2 )

'' Set up the ball size.
Ball.Rad = 5


'' Create our screen.
Screenres 640, 480, 32


'' Lock the page for drawing.
PageInit()


'' Main loop.
Do

'' Move the user paddle.
If MultiKey(FB.SC_UP) Then Paddle(0).Pos -= 3
If MultiKey(FB.SC_DOWN) Then Paddle(0).Pos += 3

If MultiKey(FB.SC_LEFT) Then Paddle(1).Pos -= 3
If MultiKey(FB.SC_RIGHT) Then Paddle(1).Pos += 3


'' Loop through all of the paddles.
For DoVar As Integer = LBound(paddle) To UBound(paddle)


'' Bounds checking.
If Paddle(DoVar).Pos < 0 Then Paddle(DoVar).Pos = 0
If Paddle(DoVar).Pos > 479 - Paddle(DoVar).Size.Y Then Paddle(DoVar).Pos = 479 - Paddle(DoVar).Size.Y

Scope

'' Whether or not there was collision.
Dim As Integer Col


'' A container.
Container


'' Check the ball against the paddle.
If Paddle(DoVar).Side = Pong.Lside Then


'' Check for absolutely no possible collision.
If Ball.Pos.Y + Ball.Rad < Paddle(DoVar).Pos Then ExitContainer
If Ball.Pos.Y - Ball.Rad > Paddle(DoVar).Pos + Paddle(DoVar).Size.Y - 1 Then ExitContainer
If Ball.Pos.X - Ball.Rad > Paddle(DoVar).Size.X - 1 Then ExitContainer


'' Collision is guaranteed.
Col = 1


'' Right side is drawn at screensize - paddlewidth, y
ElseIf Paddle(DoVar).Side = Pong.Rside Then


'' Check for absolutely no possible collision.
If Ball.Pos.Y + Ball.Rad < Paddle(DoVar).Pos Then ExitContainer
If Ball.Pos.Y - Ball.Rad > Paddle(DoVar).Pos + Paddle(DoVar).Size.Y - 1 Then ExitContainer
If Ball.Pos.X + Ball.Rad < 639 - Paddle(DoVar).Size.X - 1 Then ExitContainer


'' Collision is guaranteed.
Col = 1

EndIf


EndContainer


'' There was collision between the paddle and the ball.
If Col = 1 Then

'' Flip the velocity of the ball.
Ball.Vel.X = -Ball.Vel.X
Ball.Vel.Y = Ball.Vel.Y

EndIf

End Scope


'' Move ball position.
Ball.Pos.X += Ball.Vel.X
Ball.Pos.Y += Ball.Vel.Y

'' Increase velocity slightly each time.
Ball.Vel.X *= 1.0005
Ball.Vel.Y *= 1.0005


'' Ball bounds checking.
If Ball.Pos.Y < 0 Then Ball.Vel.Y = -Ball.Vel.Y
If Ball.Pos.Y > 479 Then Ball.Vel.Y = -Ball.Vel.Y


'' Score subtraction.
If Ball.Pos.X < 0 Then Score -= 1: Ball.Pos = Type<Pong.vect2D>( 319, 239 ): Ball.Vel = Type<Pong.vect2D>( -1 + Rnd* 2, -1 + Rnd* 2 )
If Ball.Pos.X > 639 Then Score += 1: Ball.Pos = Type<Pong.vect2D>( 319, 239 ): Ball.Vel = Type<Pong.vect2D>( -1 + Rnd* 2, -1 + Rnd* 2 )


'' Draw the paddles.
'' Left side is drawn at 0, y
If Paddle(DoVar).Side = Pong.Lside Then

Line ( 0, Paddle(DoVar).Pos)- Step ( Paddle(DoVar).Size.X - 1, Paddle(DoVar).Size.Y - 1), RGB(255, 255, 255), bf

'' Right side is drawn at screensize - paddlewidth, y
ElseIf Paddle(DoVar).Side = Pong.Rside Then

Line ( 639 - Paddle(DoVar).Size.X + 1, Paddle(DoVar).Pos)- Step ( Paddle(DoVar).Size.X - 1, Paddle(DoVar).Size.Y - 1), RGB(255, 255, 255), bf

EndIf

'' Draw the ball.
Circle ( Ball.Pos.X, Ball.Pos.Y ), Ball.Rad, RGB(255, 255, 255),,,,f


'' Our score.
Locate 1, 1
Print score

Next

PageFlip()
Sleep 5, 1
Cls

Loop Until MultiKey(1)
PageClose()
Poon King is offline   Reply With Quote
Old 07-26-2007, 12:07 PM   #2 (permalink)
Gunzfactorian Commando
 
_JaY_'s Avatar
 

Join Date: Sep 2006
Location: nEw yoRk ciTy
Posts: 2,863
_JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute._JaY_ has a reputation beyond repute.

Send a message via MSN to _JaY_
Default Re: fgdfg







__________________
_JaY_ is offline   Reply With Quote
Old 07-26-2007, 12:14 PM   #3 (permalink)
Banned
 

Join Date: Jun 2007
Posts: 183
Poon King is a glorious beacon of light.Poon King is a glorious beacon of light.Poon King is a glorious beacon of light.

Default Re: fgdfg

yes

that is my sig

cuz i r pro lah
Poon King is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT -5. The time now is 10:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34