Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sorta, DATA /READ in c++
#1
I know there is something in c++ similar to the DATA statements in qb. I want to make a simple map, you know then:

Code:
DATA 1,2,5,6,4,7,8,9
DATA 5,2,6,8,9,8,2,8
DATA 8,5,6,3,7,8,2,5
for y= 0 to ylen
   for x=0 to xlen
      read, z
      map(x,y)=z
   next
next
Im brushing up on arrays in c++ cause im sure it will need them. is this the way to do it in c++ or is there a more effective way?
Reply
#2
Hmmm, "C" newcomers, you should change the chip. I understand that you come from QB, but C is different and you should try to forget those crappy QB facilities Wink

There is no such READ/DATA thing in C, for god's sake Smile You'll have to read from a file or do direct asignations. Note that in C you can give values to a whole array in a row, so READ/DATA is not needed. For example, imagine we need a 5x5 map (not bigger 'cause I'm lazy Wink )... You can define your array this way:

Code:
char map[5][5]={{1,2,3,2,1}.{2,1,2,2,2,},{2,3,2,2,1},{2,3,2,2,1},{2,1,1,1,1}};

I guess I don't have to say that you can split the lines so it is more clear for you to write the data.

Anyhow, I'd sugest you to use files instead, it is better just changing a single map file than having to recompile after making a simple change in the map.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
thanx man, thats what im looking for. I know it is way off DATA/READ but that the only way i could descibe it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)