tlist timage global

BlitzMax Forums/BlitzMax Beginners Area/tlist timage global

mudcat(Posted 2005) [#1]
Been going through the two tuts 1)beginners guide to max 2)how to make astroids in an hour.

first question-why- global image:timage? does it have to do with mem managment?Guess I'm asking what is timage ,And why global?Because u can use it in functions directly?

second question-In different types,ex.-type tship and type trock-they have this line...global list:Tlist...if u didn't make it global then a new list would be made everytime u made a new object?Also making it global u can use it in functions directly,right?


Diablo(Posted 2005) [#2]
1. Normaly you would global a load of images at the start of you code:
global image1:Timage
global image2:Timage
global imageN:Timage

and then create a function that loads the images later:
function LoadGraphics(path$)
image1 = loadimage(path$ + "\image1.png")
image2 = loadimage(path$ + "\image2.png")
imageN = loadimage(path$ + "\imagen.png")
end function

its basicaly so that you dont have to load graphics mid game and can access them at any point for anything you might want todo with them.

TImage is the type that stores info about a image e.g:
image1.width ' < returns the width of the image


2.Yes it also helps naming conflicts too. You didn't put it in the type globized you would put it outside the type and that would mean you couldn't have loads of TLists called List.

It also means that you can access the global list without creating an intances of the actual type using:
TShip.list



mudcat(Posted 2005) [#3]
Diablo,
Thanks- that helped a bunch


mudcat