Public Group

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

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

## Recommended Posts

##### Share on other sites
Quote:
 Original post by cosmiKI 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 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 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 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 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 on other sites
Quote:
 Original post by jykI 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 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 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 on other sites
Quote:
 Original post by cosmiKI 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

1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633762
• Total Posts
3013727
×