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.

Newcomers DBPro Corner / Data Statements Help!

Author
Message
Rock
19
Years of Service
User Offline
Joined: 31st May 2005
Location:
Posted: 1st Jun 2005 04:36
Hi

I'm quite new to programming, I've already programed a 2d pong(newbie favourite) and I'm working on a 2D Breakout type game

1 BIG PROBLEM though :

In my game I use a 3D array (bit adventurouse eh!) to program in levels eg.

data 1,2,3,0,3,2,1

0 being no block
1 being red
2 being purple
3 being blue

I also have a bit on the start munu where users can enter a password and the computer should read a certain bit of data into an array and take the user to the level of their choice, but I can't figure out how to make the computer read data for 1 level when I have 5 or 6 levels (blocks of data each having 5 lines and each data statement holding 10 pieces of data)

read below if I don't make sense
Zone Chicken
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: `~-..-~`~-..-~`
Posted: 1st Jun 2005 07:20
Use lables and the read(lablename) to point to the data sequence you want to be read inside of the arrays and put your arrays in functions to be called seperately as levels, Scouseknight wrote a excellent tutorial on how to make a pacman game with multiple levels.

http://forum.thegamecreators.com/?m=forum_view&t=28351&b=5

Your signature has been erased by a mod -- please resize to under 600x120...
Rock
19
Years of Service
User Offline
Joined: 31st May 2005
Location:
Posted: 1st Jun 2005 07:27
Sorry guys, code didn't quite work out, no worries though

here it is:



PS. dont try and compile thise code its only an example!

This is in the main loop (but doesnt really matter)



I'd greatly appreciate it if someone could help me

Thanks
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 1st Jun 2005 08:03 Edited at: 1st Jun 2005 08:05
You should look into the restore command, and use labels for each section of level data.

ie

level1:

data 1,2,3,0,0,0,...
data 0,1,3,2,0,...
data blah...
data blah...,0,1,99

level2:
data 0,0,1,1,2,3,1,...
data 0,1,2,2,2...
data ....,1,1,99

level3:
data ...
data ...
data ...,99

etc...

Now when you want to read in level 2 you use the restore command prior to you read loop.

restore level2

to read level 3

restore level3


You see the restore command sets the internal pointer for the read command. It basically directs the read command on where to begin. As long as your blocks of data are broken up by labels, you can restore to any label.


=======
If all levels do not contain the same number of data elements, it's usually a good idea to have an End of data (kind of like end of file delimeter). So let's say a value off 99 means end of level.

You would then be able to chaeck for this value in your loop that reads the data, to know you are at the end

~zen

Rock
19
Years of Service
User Offline
Joined: 31st May 2005
Location:
Posted: 1st Jun 2005 18:13
Thanks for all your help guys.

If I were to put my data statements in a function, how would I do it? I've never really used functions before. would I put them all in one function?, where would I put the function?, How would I read out of the function?

also if I have a password a bit like this, how would it work?

input password$

if password$ = "lev1" (then what?)
if password$ = "lev2" (then what?)



Thanks again
Rock
19
Years of Service
User Offline
Joined: 31st May 2005
Location:
Posted: 5th Jun 2005 05:34
Could someone please show me how to do this

thanks

Rock

Login to post a reply

Server time is: 2024-09-23 21:19:59
Your offset time is: 2024-09-23 21:19:59