Game Design Music and Art

arrays – gaurdianAQ

gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
I am wondering why won't this array work I am using blitz3D and I followed the tutorial except made a few changes it says out of bounds or something like that
Graphics 800,600
Dim alien$(rows,columns)
For rows = 0 To 2
For columns = 0 To 14
alien$(rows,columns) = FindChar$(rows)
Next
Next
For rows = 0 To 2
For columns = 0 To 14
Write alien$(rows,columns)
Next
Next

Function FindChar$(i)
If i = 0
Return "<O>"
Else If i = 1
Return "<O>"
Else If i = 2
Return "<O>
EndIf
End Function

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I think there is a small misunderstanding. I'm not sure what you're trying to do, but you have to define a array like this. Array(1,1) The numbers define how many rows and columns. It was an illustration as for rows an columns. I'll do my best to give you my interpretation of the code you're doing.


graphics 800,600

Dim alien$(2,14)

for rows = 0 to 2
for columns = 0 to 14
alien$(rows,columns) = FindChar$(rows)
next
next

for columns = 0 to 14
for rows = 0 to 2
write alien$(rows,columns)
next
print ""
next

;You can do it reverse, but you can space it if you do it in this order.

function FindChar$(interger)
if interger =< 0 ;No need for multiple lines, we know its never going to be 3 so we'll always get the same response.

return"<O>"

endif

end function

I had some real use for this technique. Making 300 squares by hand is tiring so I built this program. I also use it for rotating models and saving them as bmps to create 3d illusions.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
how could I transfer this into a space invaders style of thing I came up with the code to move the aliens I just need the code to draw them and I think I can figure out the rest
gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
I think I want a multidimensional array
Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Thats all you need to draw them above. It draws them. At least it should, I'll check.

Edit: I don't understand whats wrong with it.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

[This message has been edited by Mene-Mene (edited January 17, 2007).]

gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
I got it so it shows the rows but now I need to somehow get them to move I have not figured out how yet
Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Put them in a type.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
I did that I think and I used the text command
Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Use the type loop to move them all.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
what is the type loop how do I use that?
gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
is that the for each next loop?
gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
can you demonstrate how this would look? with <O> being the alien?
Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006

Type AlienT

Field X
Field Y
Field String$

End Type

for a = 0 to (2 * 14)

Alien.AlienT = new AlienT

next

for all.AlienT = each AlienT ;!!!! This is the loop
All\String$ = "<O>

next

;I want to move aliens right 1 pixel.

for all.AlienT = each AlienT
All\X = All\X + 1
next

fixed now.
------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

[This message has been edited by Mene-Mene (edited January 18, 2007).]

gaurdianAQ

Member

Posts: 106
From:
Registered: 01-15-2007
um this code does not work? I tryed modifying it to see if I could get it to work but no dice