Game concept

The Partridge Family were neither partridges nor a family. Discuss.
uglypie
Posts: 21
Joined: May 5th, 2012, 5:05 pm

Game concept

Post by uglypie » May 11th, 2012, 10:15 pm

I've started thinking about a new game idea, and thought I'd post it here. I haven't written any code yet because I want to have a good plan first. If you have any suggestions or comments about the game, or how it could be implemented, I'll appreciate it :) Two images are attached to illustrate the idea.

Here is the idea:
A bomb or several bombs are dropped from the top of the screen, and will fall like they are normal physical objects. The same goes for collisions with walls etc. The goal is to get the bombs safely into the finish positions before they explode. This is done by carefully placing certain building blocks around the level before the bombs are dropped. Building blocks are obstacles that alter the course of the bomb as it hits it. It can for example be a tilted line, making the bomb roll off one end. It can also be a spring, making the bomb be thrown up into the air. Other things I've thought off include portals and gravity changers. The player is given a certain number of each building block for each level, and the challenge comes from placing them in the correct positions to get the bombs in the goals.

Implementation:
I'm thinking that I need at least 3 game states: the menu screen, the game state, and a map editor state.

The building blocks will be selected with the mouse, and their rotation with the arrow keys.

Possible classes (objects):
BombMan - The monster that flyes back and forth, dropping the bombs
Bomb - The bomb itself
TopFrame - The top part of the screen
BottomFrame - The bottom part of the screen
Map - The playable part of the screen. A map can for example consist of a list of textures.
BuildingBlock - Lines, GravityChangers, Springs, etc. BuildingBlock can be a base class.
Texture - A texture defines a surface inside the map. It can be divided in foreground and background, the foreground ones will interact with the game. A texture can be the default map content created in the map editor, or it can be a building block.

Difficulties:
- Getting the bombs to behave like physical objects.
- Attaching building blocks to the map, and making them interact correctly.
- Creating the map editor


So this will probably make a good challenge! I'll post here again as soon as I have something to show for.
Attachments
menu.jpg
(79.13 KiB) Downloaded 319 times
idea.jpg
(54.9 KiB) Downloaded 319 times

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Game concept

Post by LuX » May 11th, 2012, 10:38 pm

Sounds like a nice project!
Making a realistic gravity might be a though nut to crack.
ʕ •ᴥ•ʔ

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Game concept

Post by chili » May 12th, 2012, 1:52 am

This sounds fun bro! I think the gravity won't be too difficult, basic high school physics. The making the collisions with the various obstacles could be more challenging depending on how realistic you want to get. Looking forward to following your progress. :)
Chili

uglypie
Posts: 21
Joined: May 5th, 2012, 5:05 pm

Re: Game concept

Post by uglypie » May 16th, 2012, 2:02 pm

It was cool that you used my Sokoban program in the last tutorial Chili :) I look forward to seeing your finished solver.

Anyway, I've been working on some physics to get a ball to behave naturally during collisions and such. I found some helpful articles here: http://chrishecker.com/Rigid_Body_Dynam ... s_Articles

I've used the methods described in those articles as much as possible, but also some of my own. The current program can detect and handle collisions between a ball and a line. It turns out that tangental forces like friction is hard to take into account in collisions, and that's essential to make a ball spin. I had to hack it so that the ball spins by the same velocity as it hits the wall with (kind of like the wall was extremely sticky).

When the ball has a small velocity away from the collision point, I assume that it is in contact with the surface, and it starts to roll. When the ball is rolling, I calculate translational and angular velocities by regular high school physics (block on inclined plane). It's slighly more complicated since I have gravity in both x and y directions. The ball will skip along the surface until friction takes hold, then it will roll with the relation omega = v_translational / radius.

I gotta say, making this program was a huge bag of hurt, and it's probably riddled with bugs. For example, if the gravity is negative and the ball is rolling on the ceiling, it jumps fast up and down, and I can't seem to figure out why.

Nevertheless, I'm posting it to "save" the progress so far, and you guys can play around with it if you want :)
Attachments
Rolling ball demo Zipped.7z
(35.66 KiB) Downloaded 331 times

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Game concept

Post by LuX » May 16th, 2012, 2:31 pm

Nice work.

It seems you have trouble with putting pixels without it crashing....
Use the same method as I did in my game:

replace PutPixel with this: solves all possible drawing problems!

Code: Select all

void D3DGraphics::PutPixel( int x,int y,int r,int g,int b )
{	
	if (x <= 0) {x = SCREENWIDTH;}
	if (x > SCREENWIDTH) {x = SCREENWIDTH;}
	if (y <= 0) {y = SCREENHEIGHT;}
	if (y > SCREENHEIGHT) {y = SCREENHEIGHT;}
	((D3DCOLOR*)backRect.pBits)[ x + (backRect.Pitch >> 2) * y ] = D3DCOLOR_XRGB( r,g,b );
}
About the ball in your demo, it's of course possible that the ball is just really heavy, but I somehow expected a little more bounce off walls. Like just a little bit more... So that at the end it would spin back just a few pixels.
ʕ •ᴥ•ʔ

uglypie
Posts: 21
Joined: May 5th, 2012, 5:05 pm

Re: Game concept

Post by uglypie » May 16th, 2012, 2:39 pm

Ye, there's still some problems I haven't figured out, but I thought I got rid of the ball outside window problems. Does it happen all the time?

About the ball, if you check out the constructor for Bomb, there's a ton of parameters you can change. If you change the "coeffRestitution" closer to 1, it's gonna be more bouncy.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Game concept

Post by LuX » May 16th, 2012, 3:04 pm

Hmm... The ball bounces and weight otherwise are good, I think, but the ball loses all its power once it hits the the walls. It should have a very small, unnoticable bounce off.

And the code I pasted above is actually not the one I mean to post, lol. That was a copy from from my code before I understood Clipped pixels, I have no idea why I didn't update it in my newer ones. Oh well, it does the same thing basically.

You mentioned the problem where the ball flies outside the screen. It sometimes does, if I move the screen around. Infact it loses all collision detection for me. Anyways...
ʕ •ᴥ•ʔ

uglypie
Posts: 21
Joined: May 5th, 2012, 5:05 pm

Re: Game concept

Post by uglypie » May 16th, 2012, 3:15 pm

Ah, now I understand. The problem is that when a collision happens, sometimes the outgoing velocity is very small, and in that case, the ball should rather be in contact with the surface than bounce back and forth. I have an epsilonSpeed for this. You can set it smaller and see if that helps (it's in the constructor as well).
I think that if you move the screen around, the program is put on pause. When the ball is ready to move again, a long time has passed (large deltaT), and the ball has to move a long distance. It moves beyond the line it was supposed to collide with, and so the collision is not detected. The same things happens if you put a breakpoint somewhere in the code, and try to start the program again.

I should solve both these problems by handling contact situations better, and make some algorithm to predict collisions.

Anyway, cool that you tried the program. Hopefully I'll have a more fun version coming up soon.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Game concept

Post by chili » May 17th, 2012, 3:32 am

Thanks for sharing bro! I will definitely check this stuff out when I get off work.

The window drag problem is a bummer, but not really that big of a deal in the whole scheme of things. It can probably be fixed with some minor modifications to windows.cpp and your game code.

Does your physics model keep track of linear and angular momentum?
Chili

uglypie
Posts: 21
Joined: May 5th, 2012, 5:05 pm

Re: Game concept

Post by uglypie » May 18th, 2012, 12:07 pm

I guess you could say it keeps track of it, since I have the velocities and mass. But for the collisions I use impulses.

Right now I'm trying to convert the code to using polymorphism for collideables and drawables etc. That should make the code more understandable, and easier to extend with more objects.

Post Reply