places in game problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

places in game problem

Hi!
I am making a 2D game (using Allegro and C++) and I have such a problem. In a typical game appear lots of different places. And if we are in a one place there is no need to keep in memory bitmaps, variables etc. which are necessery in the other one. And my question is how to make passages between different places and how to solve the problem with keeping in memory variables of different places.

As for now my only idea is to create a variable (let's call it place) which keeps the number of place and make in the main game loop something like this

while(game){

if(place==1){
//things happen in place number 1
}

else if(place==2){
//things happen in place number 2
}

... etc.

else if(place==){

}
}

But as I know my programming abilities there should be easier solution of my problem. Thanks very much in advance for any help.

PS. Sorry for my English but it's not my native language.

Comments

Sign In or Register to comment.