Followers 0

# Some basic questions from beginner

## 6 posts in this topic

First of all, hello everyone.

I have already made some super-basic 2D games like TicTacToe, snake and pong. I think I am starting to understand how simple games work. Collision detection in pong is simple, because there is only one ball and 2 objects that it can hit. But when I think about some simple 2D shooter game i feel confused.. Let's say I have my character, some enemies and some platforms, on which I can jump.. How am I supposed to check the collision  of every object ( me, all bullets flying, all enemies and all platforms ). When I have 1 enemy and many bullets I can store the bullets in the array and then use loop to check the collision between the enemy and every element of the array. When I have many enemies and many bullets I can use double loop.. this is the way I see it, I have no idea if it is correct. But what if I have many elements of different types? Enemies, trees, fences, cars etc.. This topic really confuses me.. I hope everything is clear.

Second question, programming side:

In my poorly written code I am mostly using numbers instead of const variables..

// this is my code
enemy array[10];

// this is the experienced programmers code
const int MAX_ENEMIES=10;
enemy array[MAX_ENEMIES];


what is the point of doing it?

1

##### Share on other sites

Thanks a lot for the fast response, it seems clear now. I know about the Vector but I never had to use it. I made this topic because when something bothers me I can't stop thinking about it :D I am coding the Pong game while thinking about hundreds of other things.

Now I see that games are much more complicated than I thought..

Again, thanks a lot :)

0

##### Share on other sites

Yep, I am using C++, but I still don't know much about OO part of this language. In my programs I use just simple classes, constructors, destructors and friend classes. I am reading a C++ book, so eventually I will learn the more advanced techniques.

I have one more question, this time about the game loop..

I know it should look like this:

while(gameRunning)
{
handle_events();
logics();
rendering();
}


handling events is just taking the player input?

rendering.. this is obvious

but the logic part bothers me.. I see it as a main part of the loop, where most things happen. Calculating collision, velocities, tons of other stuff and at the end changing the coordinates of the objects. But finally I come to the point, where I have no idea where to move the objects and where to calculate stuff.

0

## Create an account

Register a new account