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 / My Second Pong Game

Author
Message
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 21st Nov 2004 11:15
Hi everyone, I built a pong game based off of ChrisK's well known "My First Pong Game" tutorial. I finished that, andhave decided, for practice, because I am new, to spruce it up a bit. What I would like to do first is make the collision detection better and less glitchy. The thing I have trouble with are mainly the sides of the paddles. When you are moving up or down and the ball is right above you it can get stuck bouncing around inside your paddle, I know how to detect whether or not the ball has hit the side, but I don't know what to make it do when it does. Any help on that?

For reference, I am using DarkBASIC Professional.
Thankyou Everyone.

Welcome to Hypocrite In A Box, May I change your order?
PiratSS
21
Years of Service
User Offline
Joined: 18th Oct 2002
Location:
Posted: 21st Nov 2004 11:22
What you need to look for is the offset from the position of the paddle.

So let's say you move in zposition and you detect a collision with the ball. All you need to do is subtract the zposition of the paddle from the zposition of the ball. Then divide the offset by the length of the paddle, and you got yourself a scale.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Nov 2004 16:47
When it hits the top or bottom you want it to bounce in the same way it bounces when it hits the top or bottom wall. I think this is-

a# = 180 - a#

or something like that.
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Nov 2004 16:55
i also had same idea so here is what im working on(click on the download button in right corner to download a screenshot package.

im currently working on the sounds.


Waggames

wanna join Waggames?
then visit our site at : http://www.freewebs.com/waggames
my old forum name was: The Nerd

Attachments

Login to view attachments
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 22nd Nov 2004 00:33
Ok, thanks guys, chris, I'll try that, I have a quick "off-the-topic" question, for a beginner, a complete beginner (me) what would be a good 3d modeling program to use. im not ready to use one yet, but I want to know what to ask for for christmas so ill have it when I need it... i have maya version 5 personal learning edition, but it needs a converter for import and exports, so any better ones for beginners than maya? thanks again

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 23rd Nov 2004 10:33
anyone there yet? well, i hopes so, if been trying to work tis out in code for a while, so i switched to sketching out ideas on paper, and every time i try to solve my problem, i come back to one thing. what the problem is, is that, i cant figure out how to see if the ball is hitting the far end and close end of the paddle. the only solution ive come up with, is to make it so that if the ball is within 2 x points (the paddle's width) and if it is at the very top of the paddle or bottom, and NOWHERE else, it will bounce off in a different dirrection.so the code for this would be to check if the ball hit the far face or the close face of the paddle,

rem to make sure that the ball is within the paddles width and
if ballx# > 5 and ballx# < 5.5 and ABS(z1#-ballz#) = 1.5 then ...
[\code]

that is what i think it would or should be, the key point is the equals sign, checking if (since the paddle is 3 units long) if the ball hits exactly at the edge of the paddle on the far or close side
the problem have with this is that at the moment, the ball is at a very reasonable speed, .3 units per frame, but that can't hit the far end of the paddle exactly, because it doesnt match up, so I can't figure out how to do it, because if i change the balls speed to .5, its too fast, and i can lower it to .05, but that is way too slow, this may be a vague post, hopefully not, but i hope someone can help, tahnks everyone

Welcome to Hypocrite In A Box, May I change your order?
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 23rd Nov 2004 12:24
Quote: "When you are moving up or down and the ball is right above you it can get stuck bouncing around inside your paddle"

to be simple..
couldnt you make a lock so the ball only bounces once
like
if <collides> and alrdybounce=0
<bounce>
alrdybounce=1
endif

then just unlock it when it hits the other paddle or the walls

You have just read my post!
56 exp. gained.
202 gold found.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 24th Nov 2004 03:36
The code will be the same as before but swap the x and z coordinates. Imagine you're doing the same code but with a really thin and really deep paddle, if you get what I mean.


if ballx# > 5 and ballx# < 5.5 and ABS(z1#-ballz#) < 1.5 then ...
if ballz# > (z1#-1.5) and ballx# < (z1#+1.5) and ABS(5-ballx#) < 1 then ...


It's the same code but from the top instead of from the side.
I'll explain more if you need but I've got homework to do.

Hope I helped.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 24th Nov 2004 09:57
thankyou , got that now, thanks chris, Travis, would do that but it would just go through the paddle instead of bouncing around inside it, but thanks anyway. next, i wanted to make a menu , but im not quite sure how to go about it, I want you to start at the menu, then return to the menu when you exit

Welcome to Hypocrite In A Box, May I change your order?
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 24th Nov 2004 12:09 Edited at: 24th Nov 2004 12:12
Use goto


Quote: "would do that but it would just go through the paddle instead of bouncing around inside it"

Shouldve work.. Did you check if it was at right number when it hit the paddle?

Note: The above I didn't say, your just crazy.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 24th Nov 2004 22:50
Quote: "if ballz# > (z1#-1.5) and ballx# < (z1#+1.5) and ABS(5-ballx#) < 1 then ..."

why is the second check ballx#? i don't get that part

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 24th Nov 2004 23:14
Just think about where the ball has to be to fufill those required ments.

Does it work? I haven't tested it.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 25th Nov 2004 08:08
no, i couldn't get it to work, I still can't figure out why the second check is for ballx#, but im out of it right no, got a fever and such, so ill be back later to check it out, thanks for ur help guys...

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 27th Nov 2004 22:09
Ok, I'm back, I just thought I would let you know.

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 28th Nov 2004 02:39
ok, i wanna figure out this collision problem on my own, i think i got the hang of it, the only thing i need to know is, where is the paddle being gripped? like, if thats hard to understand, where exactly is the point on the paddles that you move it by?

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 28th Nov 2004 02:50
The centre of the box.

If you make a model in a 3D editor it will be the 0,0,0 of the editor's axis.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 28th Nov 2004 04:50
ok

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 28th Nov 2004 07:16
i was thinkning and came up with this, not much different from what you showed me, it should work, im going to test it now:



Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 28th Nov 2004 07:16
no, it doesnt work

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 28th Nov 2004 09:36
well i can't get it, here is my code, is there anything wrong with this that might need changing?



Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 28th Nov 2004 17:02
Do it like this:



Should work.

The first check sees if the ball has hit the bat.
The second check sees if the ball is to the left of the bat.
If it is it bounces left
If the ball isn't to the left of the bat then it must be to the top or bottom so it bounces up/down.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 30th Nov 2004 08:19
this is what i got out of that, I think its basically exactly the same, i just changed some stuff around to match my code, but it won't work...



Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 30th Nov 2004 08:35
All Right!!! I got it, it may not be the best way, but it works, its like this but with whatever values you are using:

if ballx# > -.5 and ballx# < .5 and abs(ballz#-z1#) <= 1.5 then balla# = 180 - balla#
[\code]

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 30th Nov 2004 08:36
oops, heheh, i meant:


Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 30th Nov 2004 08:41
well actually, there should be a variable for the x value of the players, so that you could move them around for different levels, and it would be like

position 1,x1#,0,z1# and the collision checks would all be checking like this:
if ballx# > x1# - .5 and ballx# < x1# + .5

but this works for now, ill clean it all up with more gosubs and comments, thanks for ur help, i wanna do some grpahics work now, and clue what program i should use to make textures?

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 30th Nov 2004 09:02
i guess i should leave it how it is and upgrade the AI first, I wanna make it have regular pong AI, then, since the game is still kind of boring, I want to make the enemy player move slightly up or down before the ball hits it to make the ball chage direction everytime it is hit by the enemy so you can't just sit there and watch it go back and forth. but I know how to do these

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Dec 2004 05:06
If you need any help just ask here. I'm in a happy-helpy kind of mood because I came 2nd in the competition.

You don't need any special programs to make textures. Just use google images and paint.

I tell you what would be very very cool, have a ball like this:



And then change the color of the core depending on who hit it last. Just recolour the core object when it bounces.

If you could find a force field type texture for the outer bit it would look really nice.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Dec 2004 05:17
OMG just had the coolest idea.

Check this out:



I'll explain the code.

I don't know if you know what sin is but it produces a wave like graph. Look up "sine wave" on google to see what I mean.

Anyway, it basically bounces between 1 and -1 for values between 0 and 360.

wrapvalue() converts any number into a normal angle between 0 and 360. For example, wrapvalue(365) would be 5 and wrapvalue(-5) would be 355.

I had to times the sin value by 10 to make it affect it more (so it bounces between 90 an 110 rather than 99 and 101).
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 1st Dec 2004 10:14
ooh, thats cool, check it out, i messed with it a lil bit, what you think about this:



i want to have the ball change colour as it pulse i tried, but i can't get it, its ok though, i cant get the ball lined up with collision right on the right paddle

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 1st Dec 2004 10:47
ok, now that it pulses, i got the collision fixed, but i need to know how to set up a variable for the size of the forcefield, so that no matter how big or small the ball is, it will bounce off paddle, like, instead of:

if ballx# > ... and ballx# < ...

instead of that, something like this:

if ((ballsize/2)+ballx#) >... and ((ballsize/2)+ballx#) < ...

like that, or sumthing like it, but how to i get the radius or size, whatever u wanna call it?

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Dec 2004 02:49
I don't think you really need to change it because the forcefield isn't a solid thing.

I'm really impressed with your code structure.

Are you using DBC?

I think you've learnt about as much as you can from Pong. Why don't you start you're own game?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 2nd Dec 2004 05:00
Im using Darasic Pro, I wanted to learn a few more things from it, remember, its gonna be super pong, and if its a forcefield, it has force, which means it repels the paddles, whihc means it should be represented as a solid i think, or at least it loks better that way, but the last thing i was gonna do was make a menu , not just like a pause menu, but a start menu where u choose like, difficulty, options, start game, exit, etc...
I know exactly how im doing the difficulties, which is why i wanted to make a menu, and i was gonna finish this off and post it on my website, thanks for all ur help so far, lol

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 2nd Dec 2004 06:10
i think ill try the start menu on my own, don't tell me how to do it, im pretty sure how to, thanks though, here is my AI code, I will change the speed wiht the difficulty chosen, and the aimove# part is to make the paddle move slightly when the ball is about to hit it, so that it makes the ball go different directions when it hits it:


Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 2nd Dec 2004 09:21
ok, i just got my real dark basic pro, ive been working off of trial, and i had to re install, now i can't get pong to play, it just shows black screen when i execture, so tell me, how am i supposed to save my work, like as a .dba, or a .dbpro, and which one do i load? cause i can't get tit to work

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Dec 2004 23:24
Make sure sync is on its own line and get all the updates.

Also, run it in "Fullscreen Exclusive mode" (settings tab in bottom right)
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 3rd Dec 2004 04:57
ok, thanks

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 3rd Dec 2004 07:23
ok ,that problem is out of the way now, for the AI, how would i be able to check if the paddle is moving up when it does it on its own? like instead of checking to see if the key is being hit while the ball hits it, how would i do that?

Welcome to Hypocrite In A Box, May I change your order?
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 3rd Dec 2004 20:31
oh, should i do this:



Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 4th Dec 2004 02:58
Have a variable, moving

If the ballz# is greater than the playerz# then moving should be 1

If the ballz# is smaller than the playerz# then moving should be -1

If the bat is pretty much in line with the ball then moving should be 0

Adjust the bat's position with some code like this:

Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 5th Dec 2004 04:28
oh, ok, thanks, so ive decided on my next project, but im gonna need some help, i decided to make a kind of 3d world. just like a smiple matrix or rectangle or something, then u are a sphere, and you roll orund in the world, and collect coins or something

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 5th Dec 2004 20:29
Sounds like a nice step up.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 6th Dec 2004 01:11
so I have a question , should i just make the level a big rectangle, or a matrix, or what?

Welcome to Hypocrite In A Box, May I change your order?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 6th Dec 2004 02:50 Edited at: 6th Dec 2004 02:55
Make it a terrain!!

DBPro's terrains are gorgeous.

Just check out the most recent screenshot of "Mercenaries 2" in the WIP board.

Advanced Terrain is a free plugin from TGC.

EDIT__________

It's now the second most recent screenshot.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 6th Dec 2004 04:45
Ok, i have never heard of that, wanna explain how to do it?

The Uknown Element Gaming Group
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 6th Dec 2004 05:23
What I mean to ask is, is it built with code, or do you use a program to make a terrain or do you download it, or what?

<a href="http://www.freewebs.com/tuegames/home.htm">The Uknown Element Gaming Group</a>
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 6th Dec 2004 08:49
ok, nvm, i looked, u make it with coding commands, but how do i do/get a heightmap? that is what i dont understand about it. wanna explain how to make and/or get a hieghtmap to make a terrain with?

The Uknown Element Gaming Group
http://www.freewebs.com/tuegames/home.htm
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 6th Dec 2004 22:46
Get the demo of Geoscape.

There are loads of freeware programs for making height maps, Google it.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 7th Dec 2004 02:28
Download the advanced terrain plugin.

I think it has an example terrain that you could use.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 7th Dec 2004 06:30
where can i find that?

The Uknown Element Gaming Group
http://www.freewebs.com/tuegames/home.htm
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 7th Dec 2004 10:00
Wow, those are amazing graphics, I was gonna download the mercenaries 2 demo to see the graphics in actcion, but it takes my computer 2 hours to downlaod that, so the frame rate is probably gonna be like 10 fps. so, i like what i see and want to make it a terrain lol, tell me where to get this pluggin.

The Uknown Element Gaming Group
http://www.freewebs.com/tuegames/home.htm

Login to post a reply

Server time is: 2024-09-23 06:31:14
Your offset time is: 2024-09-23 06:31:14