Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Arrays are NOT my strong point... Array help needed.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Leftover




PostPosted: Sun Jan 23, 2005 1:30 am   Post subject: Arrays are NOT my strong point... Array help needed.

Working on a project with Rewrite... Trying to basically "preview" my maps that I made using G's map maker.

What I wanted to do was the following: Have 1 folder for each map. In each map folder, another folder with all the tiles in it, the original bmp of the map I tiled, the map file it self (mapname.map) with the proper co ords in it, and another file (mapnamemap.dat) with the array sizes in it (tiles across and tiles down).

I tried to modify an array Rewrite made me but was unsuccessful.

code:

setscreen ("graphics: max;max")

var tilenumber : int := 30
var stream : int
var size : int := 32
var size2 : int := 36

open : stream, "world.map", get

var pictures : array 1 .. size, 1 .. size of int
var pic1 : int := Pic.FileNew ("001.bmp")
var pic2 : int := Pic.FileNew ("002.bmp")
var pic3 : int := Pic.FileNew ("003.bmp")
var pic4 : int := Pic.FileNew ("004.bmp")
var pic5 : int := Pic.FileNew ("005.bmp")
var pic6 : int := Pic.FileNew ("006.bmp")
var pic7 : int := Pic.FileNew ("007.bmp")
var pic8 : int := Pic.FileNew ("008.bmp")
var pic9 : int := Pic.FileNew ("009.bmp")
var pic10 : int := Pic.FileNew ("010.bmp")
var pic11 : int := Pic.FileNew ("011.bmp")
var pic12 : int := Pic.FileNew ("012.bmp")
var pic13 : int := Pic.FileNew ("013.bmp")
var pic14 : int := Pic.FileNew ("014.bmp")
var pic15 : int := Pic.FileNew ("015.bmp")
var pic16 : int := Pic.FileNew ("016.bmp")
var pic17 : int := Pic.FileNew ("017.bmp")
var pic18 : int := Pic.FileNew ("018.bmp")
var pic19 : int := Pic.FileNew ("019.bmp")
var pic20 : int := Pic.FileNew ("020.bmp")
var pic21 : int := Pic.FileNew ("021.bmp")
var pic22 : int := Pic.FileNew ("022.bmp")
var pic23 : int := Pic.FileNew ("023.bmp")
var pic24 : int := Pic.FileNew ("024.bmp")
var pic25 : int := Pic.FileNew ("025.bmp")
var pic26 : int := Pic.FileNew ("026.bmp")
var pic27 : int := Pic.FileNew ("027.bmp")
var pic28 : int := Pic.FileNew ("028.bmp")
var pic29 : int := Pic.FileNew ("029.bmp")
var pic30 : int := Pic.FileNew ("030.bmp")


for i : 1 .. size
    get : stream, skip
    exit when eof (stream)
    for j : 1 .. size2
        get : stream, pictures (i, j)
    end for
end for

close : stream

procedure mapworld
for i : 1 .. size
    for j : 1 .. size
        if pictures (i, j) = 001 then
            Pic.Draw (pic1, Pic.Width (pic1) * (j - 1 + changex), maxx - Pic.Height (pic1) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 002 then
            Pic.Draw (pic2, Pic.Width (pic2) * (j - 1 + changex), maxx - Pic.Height (pic2) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 003 then
            Pic.Draw (pic3, Pic.Width (pic3) * (j - 1 + changex), maxx - Pic.Height (pic3) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 004 then
            Pic.Draw (pic4, Pic.Width (pic4) * (j - 1 + changex), maxx - Pic.Height (pic4) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 005 then
            Pic.Draw (pic5, Pic.Width (pic5) * (j - 1 + changex), maxx - Pic.Height (pic5) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 006 then
            Pic.Draw (pic6, Pic.Width (pic6) * (j - 1 + changex), maxx - Pic.Height (pic6) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 007 then
            Pic.Draw (pic7, Pic.Width (pic7) * (j - 1 + changex), maxx - Pic.Height (pic7) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 008 then
            Pic.Draw (pic8, Pic.Width (pic8) * (j - 1 + changex), maxx - Pic.Height (pic8) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 009 then
            Pic.Draw (pic9, Pic.Width (pic9) * (j - 1 + changex), maxx - Pic.Height (pic9) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 010 then
            Pic.Draw (pic10, Pic.Width (pic10) * (j - 1 + changex), maxx - Pic.Height (pic10) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 011 then
            Pic.Draw (pic11, Pic.Width (pic11) * (j - 1 + changex), maxx - Pic.Height (pic11) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 012 then
            Pic.Draw (pic12, Pic.Width (pic12) * (j - 1 + changex), maxx - Pic.Height (pic12) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 013 then
            Pic.Draw (pic13, Pic.Width (pic13) * (j - 1 + changex), maxx - Pic.Height (pic13) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 014 then
            Pic.Draw (pic14, Pic.Width (pic14) * (j - 1 + changex), maxx - Pic.Height (pic14) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 015 then
            Pic.Draw (pic15, Pic.Width (pic15) * (j - 1 + changex), maxx - Pic.Height (pic15) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 016 then
            Pic.Draw (pic16, Pic.Width (pic16) * (j - 1 + changex), maxx - Pic.Height (pic16) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 017 then
            Pic.Draw (pic17, Pic.Width (pic17) * (j - 1 + changex), maxx - Pic.Height (pic17) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 018 then
            Pic.Draw (pic18, Pic.Width (pic18) * (j - 1 + changex), maxx - Pic.Height (pic18) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 019 then
            Pic.Draw (pic19, Pic.Width (pic19) * (j - 1 + changex), maxx - Pic.Height (pic19) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 020 then
            Pic.Draw (pic20, Pic.Width (pic20) * (j - 1 + changex), maxx - Pic.Height (pic20) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 021 then
            Pic.Draw (pic21, Pic.Width (pic21) * (j - 1 + changex), maxx - Pic.Height (pic21) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 022 then
            Pic.Draw (pic22, Pic.Width (pic22) * (j - 1 + changex), maxx - Pic.Height (pic22) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 023 then
            Pic.Draw (pic23, Pic.Width (pic23) * (j - 1 + changex), maxx - Pic.Height (pic23) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 024 then
            Pic.Draw (pic24, Pic.Width (pic24) * (j - 1 + changex), maxx - Pic.Height (pic24) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 025 then
            Pic.Draw (pic25, Pic.Width (pic25) * (j - 1 + changex), maxx - Pic.Height (pic25) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 026 then
            Pic.Draw (pic26, Pic.Width (pic26) * (j - 1 + changex), maxx - Pic.Height (pic26) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 027 then
            Pic.Draw (pic27, Pic.Width (pic27) * (j - 1 + changex), maxx - Pic.Height (pic27) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 028 then
            Pic.Draw (pic28, Pic.Width (pic28) * (j - 1 + changex), maxx - Pic.Height (pic28) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 029 then
            Pic.Draw (pic29, Pic.Width (pic29) * (j - 1 + changex), maxx - Pic.Height (pic29) * (i + 3 + changey), picCopy)
        elsif pictures (i, j) = 030 then
            Pic.Draw (pic30, Pic.Width (pic30) * (j - 1 + changex), maxx - Pic.Height (pic30) * (i + 3 + changey), picCopy)
        end if
    end for
end for
end mapworld


Basically I took out the static assignment of size and size2, and put an open stream worldmap.dat, get, get : size, size2, and all I get is errors.

I missed the lesson we had on Arrays so that is why I need help Smile.

So, to recap, I want to take what I have above, remove static assignment of size and size2, and get them from another stream, worldmap.dat, that only contails 2 lines, with tiles across and tiles down, so it will display the proper map the way I need it. Thanks in advanced.
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sun Jan 23, 2005 12:39 pm   Post subject: (No subject)

http://www.compsci.ca/v2/viewtopic.php?t=366&highlight=arrays
Leftover




PostPosted: Sun Jan 23, 2005 12:55 pm   Post subject: (No subject)

Yeah I already read through that, several times, as well as andy's, but neither explain my situation.
MysticVegeta




PostPosted: Tue Jan 25, 2005 12:26 pm   Post subject: (No subject)

Leftover wrote:
Yeah I already read through that, several times, as well as andy's, but neither explain my situation.


I think i saw a post somewhere which used arrays to divide the images into secions or somthing like that. I will post it when i find it. Doh!
cycro1234




PostPosted: Tue Jan 25, 2005 1:01 pm   Post subject: (No subject)

Well first off, you could use an array to store all those picture variables.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: