Jump to content
  • Advertisement
Sign in to follow this  
cosmiK

My story and path to my dream games... Can you help w questions/concerns?

This topic is 3453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there everyone, Wanted to start by introducing myself... well what is relevant to this post anyway! I am an aspiring game programmer, plain and simple. I started with Qbasic back in the day, and then stopped. Just recently, about a month ago I decided to learn the language that I always wanted to learn, C++. I am almost done "Thomson - Beginning C++ Game Programming". I've just started learning classes. I've also done a handful of tutorials using Allegro and have since been able to make a simple pong game(more on that in a bit), a very simple tile based 'game', and some other text based games - tic tac toe i believe. I've also looked in to C#, as well as DarkBasic but really want to focus on C++. I know that you have probably heard many people who are just beginning learning ask how to make the next MMO or such ... BUT my goals/dreams even though large, are not that big and are 'fair': My 2 major goals are 2D and 3D. For 2D, it is Mario / Platformer game... perhaps something resembling the NES/SNES Mario, or Sonic for the genesis. Or elements of Contra or other projectile based and colorful platformers. For my 3D aspiraitons it would also have to be something like super mario 64 or even dragon valor for the ps1... not much in graphics... but very fun and colorful and creative. I think I want to be well on my way writing 2D games before I move on to 3D... ( so I will not post on that till i'm comfortable with 3d). So I have couple of requests and questions for all of you out there who are above and beyond my level, or even in a completely other dimension. I will start with the more specific questions, and concerns I have, and hopefully some of you can help me with resources and assistance. The only way I can perhaps 'give back' is to write full fledged tutorials when i DO get to that level - a step by step guide for all the me's in the future, who want to climb their way up. { Perhaps I can start an entirely new section / post for this, specifically and specially assist people at their level of understand to raise their knowledge to where they want to go, or give them a lift up !? } anyway... back to the Now... [Firstly... mathematics.] My pong game is super simplistic. it is 2 players. the ball detects hitting on the top and bottom (thus bouncing off), hitting the 2 paddles (in front only, not on the sides of the paddle) and then boncing back, and hitting the left/right edges, and thus causing p1 or p2 to ++score. - Biggest Issue. I don't use geometry... i only have 4 directions :(... very unrealistic. I am not really good with math... so i want to implement actual angles in my game. I'm not sure what else is involved? Friction? Speed of the paddle moving while getting hit by the ball? etc? or does it randomly change angle when hitting the paddle? I see this as a GREAT starting point... 4 directions is very limited with either x or y increasing or decreasing by 1 usually. I know I can apply this newfound understanding to other games... such as using a mouse to aim or a platform scroller... say mario has a laser gun, that can be aimed with the mouse, etc.... haha mario with a gun! >> Can someone please help me with the conceptual backing of this geometry of pong, that can help me apply it to even a brickbreaker game, and perhaps a simple snooker/pool game... or someting that has balls bouncing against each other and borders. I think some code will help, but i've found my lack of conceptual understand is probably the biggest issue, if I understood it conceptually I could code it... because I was able to code my 4 directional pong game without much guidance at all. Do you perhaps recommend any tutorials that start with a proper/true pong and work from there to a brick breaker and perhaps a snooker game... or even an asteroids clone? This seems like a great logical step. I do appreciate any help, but would prefer online tutorials, and personal help as opposed to buying a book, money isnt the easiest thing to come by right now. [2D Scrolling] [Tile Based Collision Detection] I made a basic tile 'game'. I used an array of x20,y15 - 32x32 tiles on a 640x480 screen. i used 1s and 2s to denote the tile type. So i managed to draw these tiles to the screen, and create a flying 'player' that is limited by the screen (only stays within it). - Conceptually I am drawing out a plan to implement collision detection. Basically scanning surrounding tiles (2 possible tiles for each direction, 8 surrounding in total). and checking wether they are solid. If the next move places one of the player pixels... or edges rather ((x,y), (x+w,y), (x,y+h), (x+w, y+h)) in the next tile, and if that tile is solid, then don't make the move, or the ++x/++y... etc... then i would just implement a jump which would create a counter that would ++y for jumpHeight = 10, etc etc... so that is my basic idea. I will devote tonight to try and code that... I think once I get one direction done, the rest will be similar just changing some math around. Any suggestions with this? Or how any of you have or recommend implement tile based collision detection? I am also interesting in how to scroll the entire level, and have an array larger than that in order to implement scrolling. This isn't the biggest thing on my mind though. [Physics/Maths in a 2D Scroller] What physics are relevant in a mario/sonic type scroller? I know that mario moving isn't just x = x + speed... or is he? What about sonic bouncing off springs (I know that has to do with angles and such). Right now I am at a simple ++/--x or ++/--y... mario starts slow, and then speeds up, skids, etc. How do I implement this conceptually, and then apply it to code... I guess more importantly, how do I understand it conceptually? Any help would be greatly appreciated. I know many of these questions will be somewhat answered (especially in terms of geometry) when I figure out the mathematics as I asked in my first [question]... about a geometry-true pong. [Object-Based 2D Scroller] Think of... a Hand Drawn Background, and then a hand-drawn level... these have nothing really to do with the game mechanics accept for providing a backdrop for them. Say for example I handdraw 3 bricks... that does nothing but create aesthetics... then in the game i create some objects... say this is one... platform object(brick)[10, 10, 200, 50, solid] so basically i represent my solid world in objects. such as a rectangle that is solid... and cannot be penetrated in any direction. or i create a: platform object(ledge)[200, 200, 300, 200] so basically what i did here was create a 1dimensional (line), that is a ledge... you can jump up through it, but u will land on it while coming down. it is solid ONLY from the bottom. you can stand on it, but jump through it. then i can advance on to more complex shapes, like circles, triangles, polygons, and free-drawn shapes with points to connect them. THE MAIN POINT OF THIS IS... there are no more tiles... just objects with properties that effect the player and other objects in the game. I was getting high about this idea and I cannot wait to one day implement it? Firstly... do you guyz get what I am talking about? For me, this frees up the game world from being limited by tiles... it can be more artistic, and even dynamic. I think I will tackle this one i have gotten decent at writing a full 2d tile based scroller.... but any feedback would be appreciated... OKAY... so those are the 3 main things in my head. I am being practical and I think I've waited a long time to sign up to the forum and post. I wanted to have it well thought out first before posting as I have seen others been shunned for having flighty dreams and desires of going from no C++ knowledge to writing the next wOwarcraft overnight. I am not like that. I am willing to take the steps... HOWEVER, it is not easy going at it alone. The internet is a vortex of information that I'm not that great at navigating. I think i've done great so far finding what I have found, but I really need help. So please help me out, and remember I am a beginner. I would very much appreciate resposes to my first concern. As in... implementing and understand basic geometry for a pong game. How would I do this? Also, last question... would it be useful for me to take a look at the C++ workshop listed here in the forum. As I have mentioned I am current reading Begining C++ through Game Programming by Thompson... but it's old and even from the looks at it it seems limited. It's great, because he takes his time and explains everything very clearly... but i feel i might be missing out. Thanks for the taking the time to read my length post. I thought that my first post should be an introduction to where I am at, what my thoughts are and where I hope to go from here, so that I can get the guidance I need, and grow, and then help others along the way too! If there are any other forum sections that I should be posting to please advise me, but since I am a beginner I thought this would be the best place to start! :) - cosmiK

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by cosmiK
I am not really good with math... so i want to implement actual angles in my game.


Ok, first off, this is an insurmountable obstacle if you intend to make an actual 3D game. It is very VERY math intensive. I would argue that what a person can do in the way of 3D games without grasping the basics of vector calculus is very limited.

As for your 2D stuff, I find that pretty much all you need to know is a bunch about vectors. Once you understand things like magnitude, normalization, etc. you can use them to make basic acceleration/forces/bouncing and more. However, this does require a certain understanding of trigonometry. In my experience, you NEVER have to deal with angles in simple 2D games... you do it entirely with vectors. To make an object have inertia, give it a velocity vector denoting how much it travels each frame. To accelerate that object, add a force vector to the velocity vector each frame. Realistic gravity is produced by adding a down vector to the velocity vector for each object.

As for the object-based side scroller you are definitely on the right track of how you should break this down into objects. With regard to the general structure of it, the way I dealt with this was with the use of object-oriented programming. By making a class for a basic collision prop, I was then able to build a number of more specific classes through inheritance. To the game, it called the same collision-detection functions for all the objects, but the functions called were overridden by more specific collision-detection code for different shapes (spheres, triangles, or the special objects you described). In my experience, it helps to do away with the tile system as soon as possible. You can define the positions of objects as coordinates (stored in a two-component position vector), and define these objects as abstractly as possible through the use of classes.

I need to go at the moment, but I might be able to get back to you about more of the specifics of the pong game. In short, use vectors to define the position and velocity of the ball. Bouncing off the paddles is simply reflecting the velocity vector horizontally, and bouncing off the walls is reflecting it vertically.

Share this post


Link to post
Share on other sites
Quote:
Original post by generaleskimo
In my experience, you NEVER have to deal with angles in simple 2D games...


Hows that? Even a simple ball bouncing inside of a screen requres you to find the angle of incidence and the incident ray (vector). Dot-product also comes into use a lot since you often need the angle between two vectors.

I do agree that 3d stuff can look daunting even to a mathematician and that a decently complex 2d game is not far behind, but these obstacles can and often are overcome with the use of simple math libraries, which box 4 years of advanced calculus courses into a single function. Just my 0.02. Anyways I would wish you luck in achieving your goals, but I believe patience would be of much higher value to you.

Share this post


Link to post
Share on other sites
It sounds like you need to brush up on linear algebra. You will need to understand vectors and matricies for 3d programming anyway, so I would suggest reading about these in theory then starting to put then into practice..perhaps you should get a good book or take an evening class. A lot of books on collision detection and graphics will have a primer at the start on vectors and matricies, which may be enough.

Additionally reading about dynamics and kinematics would help you for making objects move realistically in your platformer (you may also want to look into calculus, but I'm not sure this is necessary for basic movement). Chris Hecker wrote some really good articles on these topics.

Share this post


Link to post
Share on other sites
You don't have to be great at math to make games. Understanding what a vector is and being able to work with angles, however, is very important in both 2d and 3d games.

Share this post


Link to post
Share on other sites
Quote:
Original post by VanillaSnake21
Quote:
Original post by generaleskimo
In my experience, you NEVER have to deal with angles in simple 2D games...
Hows that? Even a simple ball bouncing inside of a screen requres you to find the angle of incidence and the incident ray (vector). Dot-product also comes into use a lot since you often need the angle between two vectors.
A ball bouncing inside of a screen can be simulated using nothing more than vector math - no angles or trigonometric functions needed. To compute a reflection vector you don't need to find the actual angle of incidence; you just apply a simple vector equation that takes the velocity and surface normal as input, and outputs the resultant velocity.

I would tend to agree with generaleskimo that it's quite possible to write a simple (or even complex) 2-D game without ever dealing with angles directly.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
I would tend to agree with generaleskimo that it's quite possible to write a simple (or even complex) 2-D game without ever dealing with angles directly.

Then again, understanding of basic trigonometrical concepts is an essential prerequisite to understanding linear algebra (ie. "vector math"). And it's not as if 'angles' are such a hard concept to grasp anyway. A simple 2D game is actually a good way to learn by doing. It's so much easier to understand abstract mathematical concepts when you directly see the results in the form of some object or world moving around, rather than a bunch of numbers on your calculator screen.

Share this post


Link to post
Share on other sites
Assuming you're storing a vector as X,Y rather than angle and magnitude, you simply negate X when bouncing off a Y axis and vice versa. No angles involved. Things get tricky when you want to bounce off angled edges - but not too tricky, it's still pretty simple maths.

Share this post


Link to post
Share on other sites
Quote:
Then again, understanding of basic trigonometrical concepts is an essential prerequisite to understanding linear algebra (ie. "vector math"). And it's not as if 'angles' are such a hard concept to grasp anyway. A simple 2D game is actually a good way to learn by doing. It's so much easier to understand abstract mathematical concepts when you directly see the results in the form of some object or world moving around, rather than a bunch of numbers on your calculator screen.
Oh, absolutely. I'm not saying one shouldn't learn trigonometry; I was just responding to VanillaSnake21's assertion that (e.g.) simulating a ball bouncing around an enclosed space requires direct use of angles or trigonometry.

(My response was probably also motivated somewhat by the fact that I often see folks on these forums using angles and trigonometry in places where linear algebra/vector math would be a more appropriate solution.)

Share this post


Link to post
Share on other sites
Quote:
Original post by cosmiK

I am also interesting in how to scroll the entire level, and have an array larger than that in order to implement scrolling. This isn't the biggest thing on my mind though.

[Physics/Maths in a 2D Scroller]
What physics are relevant in a mario/sonic type scroller? I know that mario moving isn't just x = x + speed... or is he? What about sonic bouncing off springs (I know that has to do with angles and such). Right now I am at a simple ++/--x or ++/--y... mario starts slow, and then speeds up, skids, etc. How do I implement this conceptually, and then apply it to code...


- Scrolling levels can be achieved quite simply:
>> You may be able to avoid an array of every tile position, only storing non-empty tiles
>> Store screen/"camera" x and y coordinates
>> When the player is to the right of screen center, increase camerax (and so on)
>> Just subtract camerax from tilex for each tile to get its new "scrolled" screen position (same with y) (converting "game world" to "screen" coordinates)
>> Draw only tiles that lie within the visible screen

- "I know that mario moving isn't just x = x + speed... or is he?"
>> Almost! Probably the simplest way to have this kind of movement:
>> >> speed = speed + acceleration (walking applies a force directly affecting acceleration but not just setting speed=walkSpeed)
>> >> if speed > maxSpeed: speed = maxSpeed
>> >> if not Moving: reduce speed // Negative acceleration due to friction/drag
>> >> x = x + speed
>> Jumping is very similar. To jump
>> >> if not onTheGround: yacceleration = 0 - gravity //9.8 meters/sec on Earth
>> >> if onTheGround and JumpKeyPressed: yspeed = jumpPower
>> >> yspeed = yspeed + yacceleration

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!