Author Topic: Hey look, a game  (Read 2761 times)

Hey look, a game
« on: March 20, 2010, 03:09:24 AM »
Edit: Okay, so after a while of working on this er... engine test, I decided to stop this and start designing a real game. What I ended up with was a very easy game* that works with few** bullets.
INFO, SCREENSHOTS, AND DOWNLOAD

Old: Well, this is something I've been working on in C++ for the past few weeks. I'm honestly not that great with it, but I thought that since I don't have anything else to do that interests me right now, I'll just show it. I really need (or rather, want) to make lasers for this, but I can't seem to find a way to check if a circle and an ellipse has collided or not. Oh, and 3d backgrounds too.
Game with SFML & Audio DLLs
Game with only Audio DLLs
SFML is required to run the game, so download the former if you don't have the DLLs in your System32 or something.
« Last Edit: August 21, 2010, 08:51:20 PM by Raninf »

Re: Hey look, a game
« Reply #1 on: March 20, 2010, 04:46:52 AM »
Your game runs at 67fps? Or is that a bug :V

Was pretty interesting, would be much better with added graphics and whatnot. I like the bullet death animation and various other features like that though, this shows a lot of potential. I hope you continue working on it.

As for your question regarding point detection within an ellipse...

Recall that an ellipse is respesented with the equation:

(x^2/a^2) + (y^2/b^2) = 1
or
(x*x/a*a) + (y*y/b*b) = 1

x = x coordinate of the center point
y = y coordinate of the center point
a = horizontal stretch
b = vertical strech

We can substitute variables for all these values, as well as the coordinates of the point we're trying to detect, and then combine them into an equation that will return true if the point is less than radius pixels away from the ellipse, otherwise it will return false.

(x, y) = position of the center of the ellipse
(a, b) = radiants (horizontal and vertical stretch, respectively) of the ellipse
(px, py) = center of possible collision point
radius = radius of the circle centered on the point (px, py)

First, find the difference between the coordinates of both the collision circle, and the ellipse's center point.

dx = px - x;
dy = py - y;


Then, using the equation of an ellipse and the differences between the two points, we'll derive an equation that will return the distance between the edge of the ellipse and that point. We can detect if that distance is less than the circle's radius (colliding with it) to form a hitbox detection statement for the ellipse:

(dx*dx)/(a*a) + (dy*dy)/(b*b) <= radius

This equation returns true if the point is less than radius pixels away from the ellipse. After some coordinate grid angling tomfoolery, this equation should suffice for elliptical hitbox detection. Best of all, it doesn't use processor whoring trigonometry! Hooray!

EDIT: Whoops! Noticed you asked about 3d rendering as well. Since you're using C++ and this is only a hobby/side project for you, I'd recommend using one of the free libraries from this site to handle everything for you, if possible. Wouldn't want to spend too much time on it :V
« Last Edit: March 20, 2010, 05:07:12 AM by Naut »

Re: Hey look, a game
« Reply #2 on: March 20, 2010, 11:33:31 PM »
Yeah, I don't know why it's 67fps.
Wow, this helped a lot. Thank you so much for this.

Now to get rotated ellipses working...

Bitz

  • So Moe!
  • *heart attack*
Re: Hey look, a game
« Reply #3 on: March 22, 2010, 06:09:15 PM »
Heh, just making graphics work alone in C++ is an accomplishment.

What graphics library are you using (SDL, DirectX, etc)?

Edit: I just noticed that you're using the SFML library, which looks like it's really easy to use! I might consider using that over Game Maker or Flash (both which lag like CRAZY with half the number of bullets on that screenshot T_T)

Edit2: The game randomly lag spikes every second or so, changing from 60FPS to 20FPS and back constantly.
« Last Edit: March 23, 2010, 04:55:26 AM by Bitz »

Re: Hey look, a game
« Reply #4 on: March 24, 2010, 03:01:44 AM »
Yeah, about that FPS problem, I don't know why it's like that; I don't have any control over it.