Page 1 of 2

I'm a noob

Posted: Thu Apr 24, 2008 8:05 pm
by eatcomics
So, I'm making a pong clone and it is in blitz basic, I'm using text graphics
and I can't get the stinkin ball to bounce off the paddles after that I'm done, but I can't find the code on the internet. I've been lookin for an hour!

Posted: Thu Apr 24, 2008 8:15 pm
by Arce
OH, didn't see this topic before I replied to your PM.

Post the PM in here if you'd like so that others may add to what I say/help you out as well.

And tell me if it was any help.

Posted: Thu Apr 24, 2008 8:16 pm
by Arce
Also, if you could tell us a bit more about your program (what it does atm, what exactly you want it to do, what variables you're using/how it's structured) I bet I could aid you better.

Posted: Thu Apr 24, 2008 8:22 pm
by eatcomics
i could just post my code it looks like crap but I could. Im almost done If the paddles will just start working I'll be finished!

Posted: Thu Apr 24, 2008 8:26 pm
by Arce
I don't understand your most recent PM.

Tell me what's wrong with it, and what you want it to do?

Does the ball work?

I need to know what you have done and don't have done.

Posted: Thu Apr 24, 2008 8:39 pm
by eatcomics
Click here to see the hidden message (It might contain spoilers)
;PEENG PAWNG writen and developed by Eric Kline
;Thanks to my Dad for lettin me use his comp and thanks to Maneesh Sethi for writin the book that helped me develop this game
;Here we almost go
;copyright E.K. comics 2008- actually like i have legal rihgts to this!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Game!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Graphics 400, 300
;This will make random numbers
SeedRnd (MilliSecs())

;This will make the buffer backbuffer so it looks good and smooth
SetBuffer BackBuffer()


AutoMidHandle True

;Types
Type Paddle
Field x,y
End Type

Type Ball
Field x, y
Field xv, yv
End Type

;Constants
Const PADDLESTRING$ = "|"
Const BALLSTRING$ = "o"
Const UPKEY = 17
Const DOWNKEY = 31
Const PAUSEKEY = 25
Const ENTERKEY = 28
Const WARPKEY = 19
Const MENUKEY = 50
Const ESCKEY = 1

Global ballheight = FontHeight()
Global ballwidth = Len(ballstring$) * FontWidth()
Global playerheight = FontHeight()
Global playerwidth = Len(playerstring$) * FontWidth()
Global player1score = 0
Global player2score = 0
Global difficulty1 = Input ("How quick can you move?")
Global difficulty2 = Input ("How Quick can the computer move?")
Global ballX = 190
Global ballY = 140
Global ballspeedX = Rnd(-1,1)
Global ballspeedY = Rnd(-1,1)
Global youX = 20
Global youY = 140
Global compX = 370
Global compY = 140
Global ball.Ball = New Ball
Global you.Paddle = New Paddle
Global comp.Paddle = New Paddle



Function DrawHUD()
Cls
Text 0, 0, player1score
Text 380, 0, player2score
Text 0, 270, "p1 speed " + difficulty1
Text 0, 280, "p2 speed " + difficulty2

End Function

Function TestInput()

If KeyDown(DOWNKEY)
youY = youY + difficulty1
EndIf
If KeyDown(UPKEY)
youY = youY - difficulty1
EndIf
If KeyHit(PAUSEKEY)
Cls
While Not KeyHit(PAUSEKEY)
Text 0, 0, ("P1 score: " + player1score)
Text 0, 20, ("P2 score: " + player2score)
Text 0, 40, ("P1 speed: " + difficulty1)
Text 0, 60, ("P2 speed: " + difficulty2)
Text 10, 100, ("PEENG PAWNG, developed by Eric Kline, is paused!")
Text 100, 120, ("Press P to unpause...")

Wend
EndIf

If KeyDown(WARPKEY)
youY = ballY
EndIf
End Function





Function DrawPaddles()
If ballspeedX = 0
ballspeedX = -1
ElseIf ballspeedY = 0
ballspeedY = 1
EndIf
Text youX, youY, paddlestring$
Text compX, compY, paddlestring$
Text ballX, ballY, ballstring$
End Function





Function TestAI()

ballX = ballX + ballspeedX
ballY = ballY + ballspeedY

If ballY > compY
compY = compY + difficulty2

ElseIf ballY < compY
compY = compY - difficulty2
EndIf



End Function

Function Walls()
;lets see if i can get this workin stupid bouncing balls :(
If ballY <0>= 300
ballspeedY = -ballspeedY + Rand (-1,1)
ballspeedX = ballspeedX + Rand (-1,1)
EndIf

If ballX <0>= 400
player1score = player1score + 1
ballX = 190
ballY = 140
youX = 20
youY = 140
compX = 370
compY = 140
EndIf

If ballY >= youY And ballY <youY>= youX And ballX + ballwidth <= youX + playerwidth
ballspeedX = -ballspeedX + 1
EndIf

If ballY <compY>= compY + playerheight And ballX + ballwidth <compX>= compX + playerwidth
ballspeedX = -ballspeedX - 1

EndIf




End Function

;Mainloop this makes the game run
While Not KeyDown(ESCKEY)

;Functions here's where the stuff happens
DrawHUD()
TestInput()
DrawPaddles()
TestAI()
Walls()
Flip
Wend


it works fine except the comp paddle wont reflect hte ball
and the you paddle only reflects it occassionally
so im stuck!

Posted: Fri Apr 25, 2008 10:43 pm
by guyofcomics
I thought u were gonna learn C++

Posted: Fri Apr 25, 2008 11:15 pm
by MarauderIIC
You only have to post the relevant sections, instead of the whole thing :P

Code: Select all

 If ballY <0>= 300
ballspeedY = -ballspeedY + Rand (-1,1)
ballspeedX = ballspeedX + Rand (-1,1)
EndIf 
Isn't it supposed to be more like

Code: Select all

If (ballY < 0 Or ballY >= 300)
?

Unless that's what you wrote (and just didn't disable HTML in your post)

Posted: Sat Apr 26, 2008 12:25 pm
by eatcomics
yeah that's what I wrote I didn't dissable HTML so that is why...
And I changed my mind, or Arce changed my mind ...

Posted: Sat Apr 26, 2008 11:54 pm
by dejai
The definition of a noob is one who cannot solve there own problems IMO.

Posted: Sun Apr 27, 2008 3:29 pm
by eatcomics
Don't worry guys I gave up on this. I'm workin on a game with graphics. It's currently going very well, I havent had any problems and the gameplay is quite addictive!

Posted: Sun Apr 27, 2008 8:18 pm
by Arce
Hey, my apology for not helping sooner--I'll take a look at it tomorrow sometime. I've been without internet for the past 2 or so weeks, so when I've been on it's only been for brief periods of time and I really haven't had enough to debug that.

As for your later programs, I'd like to see what you come up with.

Posted: Mon Apr 28, 2008 3:34 pm
by eatcomics
I told you were to find my newest program vid on youtube in your twelve year old you tribute... So just follow the instructions I gave you...

Posted: Mon Apr 28, 2008 5:45 pm
by JS Lemming
eatcomics wrote:I told you were to find my newest program vid on youtube in your twelve year old you tribute... So just follow the instructions I gave you...
If you want people to watch your video, post the god forsaken link.

Posted: Mon Apr 28, 2008 9:13 pm
by eatcomics
http://youtube.com/watch?v=BndPvsUtbj4

Are you happy? It was intended for my friends to see so they didn't think I was slackin off... :|