Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / [Question] How to make levels.

Author
Message
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 11th Aug 2011 23:16
i want to create a game like BlasterBall. i have never created a game with levels before and i am wondering when the level goes up it changes.

Here is a link to a youtube video showing what BlasterBall is: http://www.youtube.com/watch?v=xqTAY0b5V04&feature=related

i want it so like in the video it changes the level and the map. would i do this by creating a bitmap or using tilesets (are they the same i forgot) and having a difrent one for each level. if i did do that i never done collision using a bitmap/tileset.

BTW i never tested the below code.

is this how i would do collision
vitinho444
13
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 12th Aug 2011 12:44 Edited at: 12th Aug 2011 12:46
well

I think im not the best person in here to answer.
But i got an idea

First i want to say, i think that game has another name (i mean the original). And i want to say that it's a addicted game and not a easy one to make.

Ok
I think you can use a switch case..

Hassan told / teach me this to make the menu and stuff and i think it will fit in your game.


In my game i got this:

ATTENTION: Hassan is the one you should credit not me..

First in globals put this:



I dont know if you have a menu or not so i will just make this to levels.

Ok now inside your loop where you have the game stuff. you add this:



Ok now where you have your if/else statement that checks for your score (or whatever you have to level up) just need to put:



Ok now i think it will be bugged because if you do: if(score >=2000) after the if(score >= 1000) it will say: "Hey the both are right.."
So i think you can fix this adding bools to it like this:

At globals declare the level bools:




Now in your check for score just write:



Then in the level 3:


I think this will fix, then you just need to change the numbers of the levels.

If it didnt work i dont know :S

PS: I've read your code snippet and i think the collision is good for now.. if '2' is the id of the block that the ball touchs.

C++ Medium 3.5/5
VB6 Advanced: 4/5
VB.NET Advanced: 4/5
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 12th Aug 2011 17:36
Thank you for sharing that information this will help a lot and i dont have a menu im still doing one if i run in to problems i will let you know and i belive the original was named Blasterball i had it on my very very old computer. until it broke i think wildtangent made it i played that game so much maby i should buy it from them but i decided i am just going to make it. again thank you for telling me this information.
vitinho444
13
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 12th Aug 2011 17:41
no problem but hassan was the one who told me to my game.. i just adapt to yours.

I think the original name of the concpet of the game is block destroyer or something, the name is not comming to my head..

Anyway good luck (i think you will need it because its not a easy game..)

C++ Medium 3.5/5
VB6 Advanced: 4/5
VB.NET Advanced: 4/5
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 12th Aug 2011 19:45
if it is not much of a hassle could you tell me how to make a menu mine partially works im going to be busy this week so if you can im in no rush ill probally get back to you on sunday or monday so that would be very helpfull thank you again
vitinho444
13
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 12th Aug 2011 21:27
well i can say to you what hassan told me, and after you use the code i gave you for the levels it is pretty easy to make a menu.

Ok first im gonna say to you that i will be on vacations monday to monday so i might dont answer between those days.

Ok now to make a menu:

Im gonna teach you how to make a menu like mine:

Concept:
You got an image, background.

In that image (prev. you made it) you have 2 buttons or whatever you want..

Ok i got Start Game button, and Exit button.

We will be using coordinates to check if player has clicked on start or exit.

I think this part you know how to do so i will teach you the base (the squeleton) of the menu system.

Ok inside your main loop after you added the levelup system i gave you you got the switch statement.

First you need to make another case called menu




And you are good =D

Oh wait, at your global:


you must change it to:



Ok now you just do the same for the exit button and change:


for:



And one more thing, dont forget to inside the case of the level 1 put:

dbDeleteSprite(999); // this deletes the menu background or if you want this delete the menu it self =D

Hope it helps and i read this all and im super satisfied that i wrote this without seeing my source code

Good Luck and i want to thanks Hassan for teaching me the switch case

C++ Medium 3.5/5
VB6 Advanced: 4/5
VB.NET Advanced: 4/5
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 16th Aug 2011 04:11
Well it works except for one thing... when i put dbDeleteSprite(1); in case state_level1: the text does not delete i dont understand here is the code
when i take away the dbDeleteSprite(1) works fine the dbText clears like it should but when i try to delete sprite one it dosent any way to fix this thanks in advance
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 16th Aug 2011 04:40
put dbCLS ( ) after dbSync ( )

Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 16th Aug 2011 07:47
this works however the default background is usally blue and now it is black. i have not yet made a background yet but i am worried that since it changed the back ground it might slow it down or do somthing unwanted in the future.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 16th Aug 2011 08:28
Just a remark: The way you set it up now, dbLoadImage commands in level 1 and the menu are executed every loop (that means, 60 times per second the image is loaded again and again). The dbDeleteSprite command (and any other that you will still need to delete previous level or menu objects) is also executed every loop. That's a bad idea. It decreases performance and could introduce bugs. You should design your program so that level setup and level cleanup code is executed only once, not all the time repeatedly.

A possible solution: Write separate functions to setup and cleanup your levels, e.g. LoadLevel1, EraseLevel1, LoadLevel2, EraseLevel2, etc. Then introduce "transitional" game states in between levels, whose task is only to setup or cleanup a level, and call those functions in the transitional statuses. Something like this (rough example):



I only showed level2 here but it can be done for all your levels and also for the menu. Note that designing a program structure is never easy and it's normal to restructure things a few times until you get the final solution.

You can also have a look at the Dark Invaders tutorial for ideas about how to structure a game.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 16th Aug 2011 15:27
As mireben said, don't do that, and for the black background, it's not going to cause any issues for speed, if you don't want it to be black just change the background color

Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 16th Aug 2011 19:13
Alright i will go and change the cases and i have one final question since we started talking about speed of a program, i am going to have multiple levels witch equals a lot of cases would that slow down the game or if you code it like what you are doing i won't have any speed issues? i plan on having at least 15 levels or more.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 16th Aug 2011 19:42
I think you can have a switch inside a switch:

I've never tried this method, but perhapse it's worth a try.....

The fastest code is the code never written.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 16th Aug 2011 19:51
In the meantime I have realized that the code suggestion I posted above could be much improved. So I would like to give a few more ideas to you, and at the end answer your speed question as well.

The problem with the code example I gave is that it's not efficient. You'd need three functions per level and somehow access level data (e.g. sprite numbers) in several functions, which can lead to global variables and make it difficult to separate level data from each other.

It is better to try to enclose one level into only one function, but taking care that loading and deleting happens only once. For example:



The advantage is that all resources can be local variables inside the function, so the data of one level do not mix with the data of another, yet they are easily accessible.

I can imagine an even more advanced design. Consider that if you plan 15 levels, in this arrangement you will still end up with 15 different functions. But, when you change levels, only the "map" of the level (the arrangement of the screen) should change. The way you play the game, how you display the sprites, move the player, detect collisions, count the score, etc. will be pretty much the same. Ideally, it should be possible to design general functions that can load, play and clean up any level, regardless of which level it is.

For example, your first post shows that you use an array (int map[8][8]) for your level map and display it with a for loop. If you change the contents of that array, you can show an entirely different level, without changing the loop that displays it. Maybe you don't even need to change the tileset.

If this concept is a bit too much for you to implement, then go with the "one function per level" idea first.

You don't need to worry about speed with a switch statement that has 15 branches, especially in this one-function arrangement, because then you only start a level function once, and you don't go back to the switch until the level is finished.

Do you already have at least one level done or half-done? I would advise you to make at least one level fully playable and then design how you change levels. When one screen is already working, you can study the code to see what parts of the code are the same for all levels and what can possibly be different. For example, you may find that you copy-paste the same code for level1, 2, 3, etc. then it should be put into a separate function.

There is no universally perfect way for program design, so don't be afraid to experiment.

Login to post a reply

Server time is: 2024-10-02 19:19:00
Your offset time is: 2024-10-02 19:19:00