Author Topic: Arrays, For = 0 to #, if then, random and picture control  (Read 1568 times)

Offline formula1

  • Almost Regular
  • ***
  • Posts: 243
Arrays, For = 0 to #, if then, random and picture control
« on: June 18, 2009, 06:46:32 PM »
For the visual Basic Project I've been working on, I've been using a lot of the above things
except picture control.

I want to point out that all of these things can be done with many languages and I've found them to be pretty important in a game

The idea is to show alternate versions of these things in other programming languages
Especially for C++, Ruby and Javascript since those seem to be the three languages we here are interested in learning right now

Either way a good example is the items in super mario war

in visual basic
[spoilers:1qvpj6g0]Structure Items
Dim onoff as boolean
Dim Itemname as string
Dim effect as Sub
Dim picture as pictrue
Dim path as xyfunction
Dim itemtime as timer
end structure
Dim itemz as items

Dim itemsload as items

sub itemsload
for i = 0 to itemz.length - 1
if itemz(i).onoff = true
redim itemsload(itemsload.length)
itemsload(itemsload.length - 1) = itemz(i)
else
end if
end sub

sub hit_questionbox
Dim currentitem as items
Dim xy(1) as integer
xy(0) = questionbox.x
xy(1) = questionbox.y
currentitem = itemsload(random integer(0 to itemsload.length - 1))
scene.display pic(currentitem.picture, xy(0), xy(1))
set currentitem.itemtimer.interval = 125

if timer.interval = true
if currentitem.pic.y < xy(0) + 16
scene.currentitem.pic.y = scene.currentitem.pic.y + 1 pixle
end if
end if
set currentitem.itemtimer.interval = 1
if currentitem.pic.y >= xy(0) + 16
scene.currentitem.pic.x = currentitem.path(currentitem.itemtimer.interval, x)
scene.currentitem.pic.y = currentitem.path(currentitem.itemtimer.interval, y)
end if
end sub[/spoilers:1qvpj6g0]
Now, I know this code isn't perfect, however, it does represent a good deal of what is possible
Just like this could be written in C++, it can be written in a number of other ways.
Once I get the chance, I'm going to do more work on this since I want to outsource my CNS organizer work to C++ and Java for Shegundo and Jmugen, respectively.
However, I think that having simple definitions is important.

Honestly, I don't how this stuff was so difficult to learn when I tried tutorials... In school i picked it up easily...
it was weird....
I want the wisest things to happen
If you like stuff. That stuff will always exsist.... IN YOUR MIND! OH SHNAP! UNLESS U FORGETZ IT! OR SHNAP! maybe...
Destryers Inc