buddboy Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
I'm doing a 3D pong remake (I know, its basically cliche, but I need more experience) in Blitz3D. I can't figure out how to do two things: get the other paddle to move randomly, and how to keep both paddles on screen. also I will be needing to get physics to work for the ball later on... any help will be appreciated. ------------------ |
|
buddboy Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
by the way here is my code so far.
------------------ [This message has been edited by buddboy (edited November 11, 2006).] [This message has been edited by buddboy (edited November 11, 2006).] [This message has been edited by buddboy (edited November 11, 2006).] [This message has been edited by buddboy (edited November 11, 2006).] |
|
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
Wouldn't you want player2 to move with the ball? Or at least try (so you can at least win against it). But to make it move random (for which ever reason you wish), you would probably make a varible that determines if the paddle is going to move up or down (maybe like Move_Up=1, move paddle up, if = 0 move paddle down), then use RND and SeedRND to make those numbers that dictate Move_up varible randomize. ------------------ [This message has been edited by LAVA (edited November 11, 2006).] |
|
buddboy Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
hmm... but how? i couldn't figure out how to get SeedRnd to work or how to make Rnd work either. lol im just going to wait until tomorrow when im not exhausted. yeah i would want it to move with the ball... now i just have to figure out how to get the ball to move without going offscreen... ------------------ |
|
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
Well you could do a number of things to keep on the screen. A) Position Oriented: If the ball goes past a certain coordinate make it move down or bounce off or whatever. B) Marker Oriented: If the ball's mesh intersects invisible markers (using entity alpha command) make it move down. C) Area Oriented: Make a giant invisible cube that encompasses the playing field, and if the ball is not intersecting it, make the ball move down. ------------------ [This message has been edited by LAVA (edited November 11, 2006).] |
|
Realm Master Member Posts: 1971 From: USA Registered: 05-15-2005 |
*stares blankly at 3d Code* been... so... long... since... 3d... (I suck with collisions becaue I don't know about them, and collisions are the whole point of 3d so I havn't done like ANY 3d) ------------------
|
|
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: Collisions are fairly easy in Blitz. What did you not understand? Did you see the examples? ------------------ |
|
buddboy Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
yeah collisions are pretty easy. EntityCollided, EntityCollision, and MeshesIntersecting are all pretty easy to use. good idea Lava. I was thinking about having a cube around the play area. now i just have to make it work... i couldn't figure out how to get the ball to go in the opposite direction... oh duh i just use a variable for up/down. ------------------ |
|
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: Yes, you can do that, those are really good for general collisions (if you want to do the work ) and you can use them for specific things, like those commands you mentioned helped me a ton with making the boat in my adventure demo move when the character was on it and you used the keys. What I use for general collisions is the "Collisions" command and "EntityType" command. Here is an example of this taken from the collisions exmaple with some editing: method - collision detection method. response - what the source entity does when a collision occurs. type_character=1 sphere=CreateSphere( 32 ) block=Createcube() ;Makes sphere-to-polygon collisions ( so method=2), stop (so repsonse =1) And of course use Updateworld, so that way it updates the collisions. ------------------ [This message has been edited by LAVA (edited November 12, 2006).] |
|
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
Ok, here is a quick simplified version of Buddboy's code. Just a simple setup of the ball bouncing back and forth.
------------------ [This message has been edited by LAVA (edited November 12, 2006).] |
|
Ereon Member Posts: 1018 From: Ohio, United States Registered: 04-12-2005 |
As far as the movement goes Buddboy I think the simplest and most straight-forward approach would be to set of the opponent so that if the ball is above the AI paddle then the AI will move the paddle up, and if the ball is below the AI paddle it will move it down. Give the AI a set movement speed so that the paddle will have a predictable speed (you could even ramp up the speed at higher difficulty levels for a simple difficulty increase system). This allows the coding to be simple for you, and makes the game more interesting because the player can fool the AI by bouncing the ball off walls and little details like that. ------------------ Portia The Merchant of Venice |
|
dartsman Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
hey buddboy, this should work.. or at least give you an idea about how the ball and AI paddle can be updated.. it's in C++ but written in Notepad (a quickie..) so syntax and/or code might be a bit buggy.. It pretty much explains in code what Ereon said.. but a method I used about 2-3 years ago.. most ppl will use a method such as this.. boundaryPos is the right/bottom position of the boundary, presuming that 0,0 is the top left... also the paddle in this one will slide along the X axis (left being - and right being +)... you would most likely also what a condition to not move the AI paddle when the ball is right in the middle.. this *should* just be an addition to the "if ((paddleSize.X * aiSkill) > fabs(ballPos.X - paddlePos.X))" statement with just adding "&& (fabs(ballPos.X - paddlePos.X) > paddleSize.x * 0.1)"
BTW, 2D/3D... pong is just the same, if not only just a *bit* different, converting between the two shouldn't be an issue.. ------------------ [This message has been edited by dartsman (edited November 14, 2006).] |
|
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Firstly you need to decide where the camera is going to be, so as to prevent having the camera inside the play area. Pong is really more of a 1d game. the y is never used. if you want to make a truly 3d game its going to get really hard, not to mention requiring a mobile camera to catch and see if the ball is above your paddle. You also don't want it to truely be random. If it was truely random it would be jittery. There is a couple methods you could use. 1: Random Intentions (Made that up)
2: Coordination Basically an if statement. If ballx > enemyx, move right But you make the enemy slower than the player to make up for the player's miscalculations.
------------------ |