#121010 - sirpoonga - Thu Mar 08, 2007 4:29 am
This is just a demo of what I currently have. it's just to test the physics out. I might post the nds later.
http://www.youtube.com/watch?v=6Pzcunxle8U
#121030 - Diddl - Thu Mar 08, 2007 8:41 am
very cool! I loved this game when I was I child!
#121049 - KeithE - Thu Mar 08, 2007 2:06 pm
Awesome demo - it looks like you've done a great job with the physics so far.
#121064 - sirpoonga - Thu Mar 08, 2007 5:04 pm
If you want to try it out here's the nds.
http://www.box.net/public/sqzv5223d9
This was made with PALib. This is just a tech demo with debugging options. If you want you can push start to toggle pausing. While paused you can press A to advance one frame.
It will give you the option to use stylus or DS Motion. If you choose stylus a transparent ball will appear in the middle of the screen. Where you hold the stylus relative to that is the angle and amount of force you put on the ball. If you hold the stylus on the ball it will level the table.
I have found, for some reason, if you use the DS Motion you might have to push any key once to give you the warning it isn't inserted then put the DS Motion in.
This was just to get the physics code working. I plan on using 24x24 tiles for the maze and then the maze will take up the full 512x512 background. The ball will always stay centered (except maybe when it gets close to the edge of the maze).
The maze will be user configurable. It is currently a string in this program. I will need to add fat support but unfortunately my CycloDS is having issues with fat and the part that holds the TF in on the R4 is broken. Makes it hard to try stuff out :)
If you try it out let me know what your thought on the physics are. Too fast? To slow? Too much bounce? etc... The ball is a struct with its own friction and bounce coeff. I plan on having different ball types.
#121068 - Diddl - Thu Mar 08, 2007 5:17 pm
wonderful, I have ordered a motion card cause your maze. I must see this working. :)
#121090 - KeithE - Thu Mar 08, 2007 8:45 pm
Cool, it is a great start. The collision detection seems to be working well, except it doesn't bounce off the top walls - it just makes velocity = 0 instead of flipping the sign, and sometimes the ball goes right through the top wall.
It seems like the ball is moving at a constant velocity when the DS is held at a constant angle. To be accurate, the ball should accelerate when the DS is held at a constant angle.
This code will do that:
Code: |
X_velocity += motion_read_x()*scale;
X_position += X_velocity; |
To that, you can add some friction to slow things down.
#121106 - sirpoonga - Thu Mar 08, 2007 11:58 pm
Hmmm, I can't get it to go through the top right wall but I have an idea why. I will get to that later.
I am adding velocity, it might be the scale at which I am applying it in combination with friction. In fact, if the ball is rolling along a wall it will get double friction as it is contacting two surfaces.
Summary of the code for the x axis:
Code: |
if(options.useMotion)
ball.x_force = -((float)motion_read_x()-2048)/1000;
ball_proj = ball; //projected ball for collision detection
ball_proj.x_speed += ball.x_force;
ball_proj.x_speed *= ball_proj.friction;
ball_proj.x += ball_proj.x_speed;
CheckCollision();
// ... Test for some special cases since this is frame dependant
ball=ball_proj;
DisplayBall();
|
As for no bounce on the top, oops. Wrong operator. CheckCollisions() has code at the end of it to check if the ball ever leaves the valid play area (due to a glitch or something causing the ball to go through a wall). It puts it back into the play area and resets forces and such. I used a > instead of a < for the y value when testing the top edge. That's also probably why the ball went through the wall, the fail safe didn't work :)
My CheckCollision code could probably be much better. That's what the grid of numbers in the lower left of the top screen is. The middle number is the tile the ball is on. The other numbers are the corresponding tiles. I only test for collisions of the tiles in the direction the ball is traveling. Such as if x_speed is positive I check for a collision with the three tiles to the right.
Once I get the physics squared away it's onto maze generation. I will have to add FAT support. The maze is represented as a string. Here's the string I use (with carriage returns to make it obvious how the string is put together).
Code: |
WWWWWWWWWWWWWWWW
WS H W W W
WWW H W W HW
W WWW WW W W W
WH W W W
W W W WW WH W
W W W W W W
W WH WWW
WHWWWWWWWHWW W
W W W W W
WEW H W WW
WWWWWWWWWWWWWWWW
|
Allow that to be put in a file you can make your own maze. I have a maze solving algorithm that is working that will determine if the maze is possible.
Thank you for the feedback.
You know what I might do. I have a small metal bearing. I should put it on the screen and see if I can get the screen ball to mimic real ball's acceleration.
#121174 - sirpoonga - Fri Mar 09, 2007 8:55 pm
Hmmm, I was able to have it go through a wall that wasn't the top one. not sure why since I can't recreate it.
I think it is because I am testing distance from center of ball to edge. Probably withing one frame it went fast enough to not be detected. I know what I need to do. I need to not use distance to line but determine if the projection is beyond a certain x or y line.
#121840 - HyperHacker - Thu Mar 15, 2007 6:35 am
Accurate collision detection in something like this means casting a ray out from the ball in the direction it's moving and testing if that ray intersects any objects. In 2D, that should be pretty easy; in 3D, you may well find yourself going bald. ;-)
You know, you could allow for variable-sized mazes loaded from files; the number of characters on the longest line and the number of lines determine its dimensions. That'd be pretty cool. If you handle line breaks properly we'd be able to create mazes right on the DS with a text editor!
Handling line breaks is fairly simple: Both \r and \n are line breaks, but ignore \r when it's followed by \n or vice-versa. This will work no matter which format is used.
_________________
I'm a PSP hacker now, but I still <3 DS.
#122045 - sirpoonga - Fri Mar 16, 2007 7:14 pm
The maze is being loaded off of a file. I am handling line breaks :)
However, I am thinking that the first line will contain height and width info.
Actually, my file format would be something like
Name
Height Width
[Ball details-friction, bounce]
[Maze]
Ultimately there will be an in game editor so you don't have to use a text editor.
I am redoing the collision detection. Basically, kinda like what you said. I know where the ball is, and I know where the ball is going to be after applying DS Motion and friction forces. I use circle-line and line-line intersection to determine collision. For any given wall in the immediate path of the ball I make a line around it that is radius away from the wall. Then if the line from the centers of the ball and ball projection intersect any lines it collided with it. This means the corners will have a arc around them. I found out that line-circle intersection doesn't require division or sqrt, but line-line does. However, I don't think it's going be system pushing program :)
In theory, if I get this working correctly, I can do rounded corners too.
My next concern is do I want to keep the current tile system, and use the screen edged as the edge of the maze or do I want to allow bigger mazes.
If I make the edge of the screen the edge of the maze I don't need to change anything. However, making the maze bigger I will need to fix the ball int he center of the screen. I am wondering if that will seem awkward with the DS Motion. Once I get the collision detection done I am going to switch the code to move the background instead of the ball and see what happens.
If I want to allow bigger mazes I am thinking of moving to a 24x24 tiled maze. Since the backgrounds are 512x512 that limits me to a 21x21 maze, right? I know I could go bigger than that with some extra coding but for now I just want to keep this simple. Also this allows me easily have a minimap on the top screen.
#122069 - KeithE - Fri Mar 16, 2007 9:19 pm
Scrolling the background with the ball in the center of the screen is fine. Hazardball does this, and it works very well.
#122083 - sirpoonga - Fri Mar 16, 2007 11:02 pm
:( I don't want to look like I am taking his idea for a game. That's very close to what I envisioned.
I like how well the ball is done, I wonder how to do that.
Though I am going to keep mine simple. I want to keep it as close to the wooden game as possible. Maybe add a couple of special walls/tiles/obstacles.
I am going to stick with 16x16, though it is tough to make a nice looking seamless wood texture at that size.
#122097 - sgeos - Fri Mar 16, 2007 11:40 pm
sirpoonga wrote: |
:( I don't want to look like I am taking his idea for a game. That's very close to what I envisioned. |
If that is the best way to display a rolling ball, do it. Don't be afraid to copy what works, just make sure to differentiate in your game play.
-Brendan
#122114 - sirpoonga - Sat Mar 17, 2007 2:06 am
I'm actually curious as to how he did it.
#122144 - sgeos - Sat Mar 17, 2007 9:14 am
sirpoonga wrote: |
I'm actually curious as to how he did it. |
You need a library that can freescroll your map. Then you do this:
Code: |
setCamera(player.x, player.y); |
-Brendan
#122200 - sirpoonga - Sat Mar 17, 2007 8:51 pm
I have a fixed ball. I am curious as to how he animated the ball.
#122210 - spinal_cord - Sat Mar 17, 2007 9:30 pm
I think something like this
have the sprite frames in a grid
say you want a ten frame roll. You will need 100 frames as you will need to animate the ball moving a full rotation down for every frame right.
eg 1st frame right = ten down frames, 2nd frame right = ten down frames etc
Code: |
----------[ball rolling left to right]--------->
[00][01][02][03][04][05][06][07][08][09] |
[10][11][12][13][14][15][16][17][18][19] |
[20][21][22][23][24][25][26][27][28][29] |
[30][31][32][33][34][35][36][37][38][39] |
[40][41][42][43][44][45][46][47][48][49] |- [ball rolling top to bottom]
[50][51][52][53][54][55][56][57][58][59] |
[60][61][62][63][64][65][66][67][68][69] |
[70][71][72][73][74][75][76][77][78][79] |
[80][81][82][83][84][85][86][87][88][89] |
[90][91][92][93][94][95][96][97][98][99] \/
|
then you reference your frame by using its rotation, eg if you have rotated 6 frames right you would use the 6th colomn to show the ball rolling down.
hope that helps, i might put a little demo together to show what i mean.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage
#122260 - sirpoonga - Sun Mar 18, 2007 5:10 am
I think I understand. Lots of artwork time in that :)
#122284 - spinal_cord - Sun Mar 18, 2007 10:16 am
Parhaps use some 3d software to animate it for you (or maybe just use a 3d object instead of a 2d sprite?)
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage
#122305 - tepples - Sun Mar 18, 2007 3:59 pm
What you can do is make a repeating texture and use Tetrisphere's algorithm to convert it down to a sphere shape. That will look enough like a ball to fool players who aren't Katamari addicts, even though topologically it's a donut. I can explain if you want.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#122316 - sirpoonga - Sun Mar 18, 2007 6:10 pm
I showed it to a friend of mine that is a graphic designer, he knew exactly what was going on. It's a diamond pattern that "scrolls" with a circle mask. You can see that as the diamonds don't distort as they approach the edge of the ball.
The question then is can that be done with the ds or would I still have to do the multiple images thing?
#122339 - tepples - Sun Mar 18, 2007 7:31 pm
If you want to do the plain scrolling pattern, then yes, you can clip that to a circle in software. Should I make a demo of what various methods would look like?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#122401 - sirpoonga - Mon Mar 19, 2007 4:34 am
If you wouldn't mind, that'd be cool.
#122404 - tepples - Mon Mar 19, 2007 4:35 am
On a ball with a diameter of how many pixels?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#122440 - sirpoonga - Mon Mar 19, 2007 10:40 am
14
#122858 - sirpoonga - Thu Mar 22, 2007 11:46 pm
I was thinking about how to do this. Is there no hardware support for blitting? Otherwise I know how I can use a bitmap mask to work with software.
#129465 - OrR - Wed May 23, 2007 1:11 am
Any chance this gets made into a full game? Because it's awesome and I want to play more of it! :)
#130146 - spinal_cord - Thu May 31, 2007 9:19 am
How's the ball animation going? is this game still being worked on?
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage
#131386 - sirpoonga - Thu Jun 14, 2007 11:23 pm
I haven't touched this in awhile, sorry. Been pretty busy.
I haven't even attempted the ball animation. I am still confused on how to make that work. I don't know how to clip a texture. Also note that i am using palib.
I am stuck on the physics. right now. Every once and awhile the ball just moved to (0,0). I know when this occurs. It's when the ball collides with a corner.
I do want to work a little more on this before I go to a large lan party in august. That would give me a great opportunity to get some hands on testing.
I might be switching to palib's 3D engine since there's been some good advances in that. This will allow me to have animated tiles. It would still be 2D though. Unless I find it easy to add a sphere on top of a bunch of tiles sprites. Then I can just transform the sphere to make it rotate :) I haven't done 3D programming in about 7 years though.
I will get the basics working with the 2D engine first though. Gotta take small steps :)
#131389 - spinal_cord - Fri Jun 15, 2007 12:18 am
I have started a similar demo, based on the ball demo on the motion card homepage. I had a few problems with collisions at first, I was using standard box collision, but later realized I had to check more points. Its not as far on as yours yet, just a ball and a tile map for collisions. larger than screen maps should be no problem.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage
#131397 - sirpoonga - Fri Jun 15, 2007 2:13 am
I am doing collisions based on math, I screwed up a couple parts. I just have to sit down and work on i some time. I know what needs fixing.
#131401 - sirpoonga - Fri Jun 15, 2007 4:03 am
edit
#131424 - DrTeo - Fri Jun 15, 2007 1:00 pm
In what software do you do the games? pls give me link...
#131438 - sirpoonga - Fri Jun 15, 2007 3:55 pm
I currently use http://www.palib.info. However, I remember reading on their forums a while ago that there is a new library coming out that I would like to try.
#132237 - sirpoonga - Sun Jun 24, 2007 10:52 pm
The box.net link has been updated. For the lazy
http://www.box.net/shared/sqzv5223d9
This is the final test before I redo the physics. The ball may go through a wall or bounce weird off corners. You can create your own maze. Put the maze.txt in your root folder (or it may have to go in a maze folder). Do not change the size of the maze. The width and height have to as shown.
W=wall, S=start, E=end, H=hole. space = nothing.
I don't have the source code in front of me at this moment but being that this is a test I think you can build invalid mazes. If I recall corrently it only checks to make sure there is a start and end. In the future I will have a maze editor in game and you will only be able to build mazes with one start and one end and there has to be a path between them.
#132238 - HyperHacker - Sun Jun 24, 2007 10:59 pm
Allowing multiple end points could be interesting. Think Race To The Finish in Super Smash Bros.
_________________
I'm a PSP hacker now, but I still <3 DS.
#132240 - sirpoonga - Sun Jun 24, 2007 11:21 pm
yeah, I was thinking about that. If I do a points based thing I was thinking of allowing multiple endings. There would be an easy, medium and hard ending point.
#132308 - OrR - Mon Jun 25, 2007 8:14 pm
Why did you make the ball almost invisible? :( I'll try to make some levels, though. :)
#132319 - sirpoonga - Mon Jun 25, 2007 10:10 pm
Sorry about that, left over from debugging collision detection.
You have to have a 16x12 maze. The edges all have to be W. The program will automatically fill the edges with W if they are not there. (If I remember correctly it does)
If you find errors with the maze generation let me know. As long as you follow the template file it should render correctly. This means the walls should smoothly connect with any walls above, below, left, and right.
Also, if the file is missing a default maze will be used. I think the same one in the youtube video.
#132324 - HyperHacker - Mon Jun 25, 2007 10:29 pm
That gives me another idea. Allow the edges not to be walls. When the ball gets out of the maze, it could either fall as if it were in a hole, or wrap around.
_________________
I'm a PSP hacker now, but I still <3 DS.
#132425 - sirpoonga - Tue Jun 26, 2007 3:30 pm
That's a good idea if I limited the maze to the size of the screen. originally I was going to have the screen be the edges. However, once I get the physics done I am going to use the entire size of the tiled background, so 32x16. This means as you scroll you will see the other edges from the wrap around.
Once I get it that far I might open source it if people want to add to it.
#132461 - HyperHacker - Tue Jun 26, 2007 10:50 pm
Isn't the background 32x32?
_________________
I'm a PSP hacker now, but I still <3 DS.
#132542 - sirpoonga - Wed Jun 27, 2007 5:48 pm
Yeah, you're right. I don't know what I was thinking.
Side note: got my slot 2 ds motion pak today :)
#132547 - tepples - Wed Jun 27, 2007 7:29 pm
True, but if you are using 16x16 pixel metatiles and a 512x256 pixel background, you have a 32x16 pixel plane.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#132559 - sirpoonga - Wed Jun 27, 2007 8:53 pm
I'm going to use PALib's 512x512 tiles background.
However, once I get the physics setup I might switch to using 2D in PALib's 3D engine. There's some really cool stuff I can do with that then.
Also, I still need to know how to mask the ball in both the 2D and 3D engine then.
#132593 - spinal_cord - Thu Jun 28, 2007 12:37 am
I was going to try this myself, but as you're a little ahead of me, i'll suggest it to you.
Doesn't palib have a 'get sprite from screen' function? it might be possible to use that to get the area of the screen that the ball is in, perhaps twice the size of the ball, manually pixel in the shape of the ball in colour 0 (transparent), should give you the mask. Then place your pattern over the ball, then the mask over the pattern. I haven't tested the idea, it might only work on a bitmap layer, I haven't even read the docs.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage
#149888 - sinkhead - Sat Jan 26, 2008 12:48 pm
Hi, is there any way I can make the ball not-transparent when using a Motion Pak? Thanks.