Online Pong Tutorial

Non-platform specific questions.

Postby Novice » Wed Mar 22, 2006 6:26 pm

This would make a simple AI, put this in draw actor of the CPU paddle.
Code: Select all
if (x>ball.x) x-=2;//this checks if the paddle is farther left than the ball and turns it back
else if (x<ball.x) x+=2;//this does the oposite
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Simple AI = great :D...Other problems :(

Postby effix » Sat Mar 25, 2006 12:41 pm

Novice wrote:This would make a simple AI, put this in draw actor of the CPU paddle.
Code: Select all
if (x>ball.x) x-=2;//this checks if the paddle is farther left than the ball and turns it back
else if (x<ball.x) x+=2;//this does the oposite


Thanks Novice it works just fine :)... although the paddle does act a little "shaky" ..
I have linked to at win32 exe of my game. see for yourself.

Now I have some other problems with my game..
Problem number 1: Physical response....
My ball act very weird. When i launch it, it sometimes bounces as a ball should.. other times it just "crawls" along side the wall.. what am I doing wrong? is it a bug or have I just configured it wrong?
My ball has the following events added to it:
Collision-->Level 1 (walls) (any side, Repeat event:yes, Event Actor only)
Collision-->Paddle_1 (any side, Repeat event:yes, Event Actor only)
Collision-->Paddle_2 (any side, Repeat event:yes, Event Actor only)
I have trid different variable settings in the physical response dialogue but with no luck. At the moment the physical response variables are set to default ( 1 )
any suggestions to whats wrong...
Problem number 2: Physical response....again! :)
I cant seem to get the ball to move at a constant speed, I assume this i related to the physical response problem.

Again I am a n00b at this so I maybe overlooking something very basic :)
Any suggestions are greatly appreciated.
regards
Effix
Game executable : PaddleBattle Alpha
GE Data files (rar) :
PaddleBattle Alpha Source
User avatar
effix
 
Posts: 14
Joined: Sun Mar 19, 2006 7:37 pm
Location: Denmark
Score: 0 Give a positive score

Postby makslane » Sat Mar 25, 2006 1:21 pm

In collision between ball and level_1, use the Physical Response:

Move: Event Only
Mass: Use Calculated
Event multiplier: 1
Event multiplier: 1
Final velocity multiplier for event actor: 1.2
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby effix » Sat Mar 25, 2006 1:26 pm

makslane wrote:In collision between ball and level_1, use the Physical Response:

Move: Event Only
Mass: Use Calculated
Event multiplier: 1
Event multiplier: 1
Final velocity multiplier for event actor: 1.2


Thanks for the reply.... but im not so sure your solution works.... it makes move even more weird... it still "crawls" along the right side of the level (no bounce) and it collides with paddle_2 then delays for a second or so before it bounce back... :)

EDIT!!
It seems to work now, I deleted evry thing and started over...
User avatar
effix
 
Posts: 14
Joined: Sun Mar 19, 2006 7:37 pm
Location: Denmark
Score: 0 Give a positive score

Postby WauloK » Wed Apr 19, 2006 12:36 pm

I had problems with PhysicalResponse too. Getting the same problems as others here. Weird.

I tried this instead but it's not working either:

Code: Select all
int x_range = 70;
int y_range = 70;
if (x < -x_range && balldirection == 4)
{
    x = -x_range;
    angle = 45;
    balldirection = 1;
}
if (x < -x_range && balldirection == 3)
{
    x = -x_range;
    angle = 135;
    balldirection = 2;
}
if (x > x_range && balldirection == 1)
{
    x = x_range;
    angle = 315;
    balldirection = 4;
}
if (x > x_range && balldirection == 2)
{
    x = x_range;
    angle = 225;
    balldirection = 3;
}
if (y < y_range && balldirection == 1)
{
    y = y_range;
    angle = 135;
    balldirection = 2;
}
if (y < y_range && balldirection == 4)
{
    angle = 225;
    balldirection = 3;
}
WauloK
 
Posts: 42
Joined: Wed Apr 19, 2006 3:19 am
Location: Sydney, Aussieland
Score: 0 Give a positive score

Postby WauloK » Wed Apr 19, 2006 1:08 pm

PhysicalResponse seems to get a random velocity and angle instead of bouncing the ball.
Sometimes the ball hits the righthand side and goes straight up until it hits the top.
Sometimes it hits the right and picks a random direction and velocity until it hits something again then does it again and again and again.
Sometimes it hits the top of the screen then bounces back and forth at the top of the screen forever.
WauloK
 
Posts: 42
Joined: Wed Apr 19, 2006 3:19 am
Location: Sydney, Aussieland
Score: 0 Give a positive score

Postby WauloK » Thu Apr 20, 2006 4:09 am

I might try recoding my above code.
I was thinking it was 0 degrees at the top, 45 to the top-right, 90 to the right, but it's 0 to the right, 45 top-right, 90 top, etc.
Might help fix things ;)

I needed to rtfm heh.
Available for Beta-testing.. PM me!
Black 16Gb iPhone 3GS
Windows 7: 2Gb RAM. Dell 9150.
WauloK
 
Posts: 42
Joined: Wed Apr 19, 2006 3:19 am
Location: Sydney, Aussieland
Score: 0 Give a positive score

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest