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.

Newcomers DBPro Corner / Need help with AI on my first pong game

Author
Message
Game Master1330
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 14th Jan 2008 20:55
I really need help cos i made a script thats working fine but the other bat dosent move and the ball is too fast. Can someone PLEASE help me?

Here is the code:



flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 14th Jan 2008 22:35
both bats move....


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/
Game Master1330
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 15th Jan 2008 19:48
they dont

HELP! IM BEEN CHASED BY 12 FIRE CHIKENS!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Jan 2008 00:35
Sorry to be down on you, but the layout of your program is atrocious.

As a new programmer, this is one thing everyone should learn first. Tutorial 2 here here is on the very subject.

Using the method you have there, programs soon become tangled and very difficult to follow.

Here's your code tidied up a bit:



Both bats move - the left one uses W and S keys.

My guess is that you are pasting code from other programs into your own program. This is OK if you fully understand what the code does. If you don't, you are asking for trouble...

TDK_Man

Game Master1330
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 16th Jan 2008 17:34
Ok sorry for the bad layout and yes i did copy it from other programs.
Im just trying to learn how to program (Im rubbish).

HELP! IM BEEN CHASED BY 12 FIRE CHIKENS!
Dewi Morgan
16
Years of Service
User Offline
Joined: 16th Jan 2008
Location: London, UK
Posted: 17th Jan 2008 06:23
Everyone is rubbish in their own eyes.
Well, a few aren't. They're just deluded

And everyone has been categorically undeniably rubbish at some point, too. Well over twenty years ago, I wrote my first program. It went:

10 #########################################

Does that make sense to you? Nor to me. But I believed that if I made a picture of a wall and saved it to tape, then played it back, it would display a wall. And a whole buncha '#' was the closest I could get to a wall.

It didn't work, I got cross and gave up, and it was a long time before I tried again.

Don't get cross. Don't give up. I regret the months I lost to programming.

Set yourself a challenge: make that player-2 bat move!

So to do that, you need to first figure out which lines are the player 2 controls, and remove them: we want the computer controlling it, not a human.

Next, once you've got that figured out and working (or rather, not-working any more)... well, you're gonna have a ball bouncing around the screen, and a bat you want to move. What's the best way to hit the ball with the bat? Have the bat in the same place as the ball, of course!

So to make an unbeatable opponent, just set the bat to be the same height as the ball every time the ball moves.

Once you've got that working, you will probably become unhappy with the way it's totally unbeatable.

So instead, change it so that instead of setting it to the same height, you just add or deduct a certain amount from the bat's height depending whether the ball is higher or lower than it.

Once you've figured that out, then you can start getting fancy Add another ball! Add bats on all sides of the screen! Add random "powerblocks" that are just like bats, except instead of following the ball, they always move down, floating down from the top. Make the ball or bats go faster or slower if the ball hits them! Make them disappear when hit! All sorts of fun changes you can make.

Sure the game itself is mindbogglingly boring... but tweaking it to be *yours* - now that's fun!

Yet another game programmer

Login to post a reply

Server time is: 2024-09-27 10:26:45
Your offset time is: 2024-09-27 10:26:45