Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Pong reset question

Author
Message
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 27th Nov 2007 14:47
Good morning to you all, how are you doing?

Now then, seeing as you should crawl before you walk/run etc..I've gone back to the roots of starter projects like the lovely pong, but now in 3d. This is from another source as I didn't know how to do it in 3d and the pong game itself is not the issue at hand, what is however is the reset code I've been messing with very little sucess. Perhaps you could help me out, I know it needs something but not sure how to phrase it, I believe the solution involves resetting the ball and paddles but its just a hunch. Well here's the code nonethless.




Coffee coffee coffee coffee coffee coffee cappacino, JAVA!
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Nov 2007 17:43 Edited at: 27th Nov 2007 18:11
your indenting is really weird...

and yeah just set all your variables back to what you want them as, then position the paddles and the ball back as well.

Why do you reset the score if player 1 wins, but not if player 2 does?

Also, I personally have nothing against gotos but a lot of the more experienced & better coders on here would most heartily recommend that you find a workaround.

I'll have a look at updating your code in a minute and edit this post.


EDIT:

OK here we go



There are a couple of lines commented out in the loading objects gosub because I don't have the pictures, but obviously just remove the little ` things to reinsert your graphics. You don't need colour object though if you are just about to texture the object do you? surely it's just wasteful code...

Anyway here your code basically just enters the main part of the game, and repeats this until one player wins in a repeat...until loop inside the main loop. Then, it goes to another repeat...until loop where the computer waits for the player to press either the y or the n key to continue. then it hits the "loop" command and goes all the way back to where the initial variables are reset, and back into the first repeat loop. This may not be the best way of doing it but at least it gets rid of the gotos as well.

I also changed it so that instead of having a seperate section for each winner (which is especially odd seeing as they seemed to be intended to be identical except for one character but in fact you missed a couple of lines out of the second one) it uses the same thing twice, simply reading out which player wins when it comes to that part of the line and then continuing.

I think that's about it. I moved the sync on command up, because it didn't seem worth having it down below where you put the sync rate command, but apart from that it was just little bits and bobs. I also changed may have some of the indenting slightly - sorry about that I just found your way confusing.

Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 27th Nov 2007 19:47
Demons Breath- Wow, thats, really nice..thank you very much. I appreciate the help, now about my indenting, its very odd I know..I've tried a few other ways I just don;'t like it, but as long as I'm posting code I'll try and keep it indeneted better. I like the method you used with the repeat..until. Thank you kindly again. Keep on coding.

zombie


Coffee coffee coffee coffee coffee coffee cappacino, JAVA!
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Nov 2007 20:34
yeah whatever's good for you obviously, it was just while I was changing some sections I changed it to the way that works for me...

And that was just a barrel-scraping method to get around using goto, there's probably a better way of doing it.

But you're welcome.

Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 28th Nov 2007 11:49
One day I shall help someone on this fourm and in that way I will repay all those that have helped before.......at 0600 hours I am freaking T I RED, but hyper..odd how those two play in isn't it?


Coffee coffee coffee coffee coffee coffee cappacino, JAVA!

Login to post a reply

Server time is: 2026-07-05 17:56:28
Your offset time is: 2026-07-05 17:56:28