Total newb working on a map building engine

Blitz3D Forums/Blitz3D Beginners Area/Total newb working on a map building engine

Sorry, I lied before. I didn't get an error message, just no output except when I run in debug mode. Then, it seems that my random number command isn't working because it always gives me the grassland tile and nothing else. For some reason, it is always picking case 0. Maybe I have misunderstood how one of these commands works.

Here is my latest version of the code for anyone that wants to look. Thanks again!

======================================================

;Draw map image and test world creation algorithm for tweaking

Global x=0 ;set coordinates x and y to 0 and make it a global variable
Global y=0
Global DrawMapImage
Global LandArea

Global Grassmap
Global Oceanmap
Global Forestmap
Global Desertmap
Global Icemap


Graphics 800,600 ;Set video mode
Setbuffer Backbuffer() ;Draw these images to the backbuffer


StartWorld() ;start main program

Function StartWorld()

Grassmap=LoadImage("Grass 1.png") ;Load Images...
Oceanmap=LoadImage("Ocean 2.png")
Forestmap=LoadImage("Forest 1.png")
Desertmap=LoadImage("Desert Sand 1.png")
Icemap=LoadImage("Ice 1b.png")
CreateWorld() ;Call Function CreateWorld
End Function
;

Function CreateWorld() ;Function begin
LandArea=Rnd(0,4) ;Pick a random number between 0 and 4
Select LandArea ;Decide which land map tile was chosen randomly above

Case 0 ;If Grass chosen, set DrawMapImage accordingly
DrawMapImage=Grassmap ;and go to function to draw this image to
DrawMapTile() ;backbuffer screen
;Repeat as needed...
Case 1
DrawMapImage=Oceanmap
DrawMapTile()

Case 2
DrawMapImage=Forestmap
DrawMapTile()

Case 3
DrawMapImage=Desertmap
DrawMapTile()

Case 4
DrawMapImage=Icemap
DrawMapTile()

End Select ;Stop decision loop

Select y ;If screen full from top to bottom, then wait for user input
Case 576
Vwait ; Wait for screen refresh
Flip ; Put backbuffer image onto front screen and show image
key=Waitkey()

Select key
Case 28 ;If Enter key pressed do the following
CLS ;Clear screen
FreeImage Grassmap ;Free the following images from memory...
FreeImage Oceanmap ;Repeat as needed...
FreeImage Forestmap
FreeImage Desertmap
FreeImage Icemap
x=0 ;Reset coordinates to 0
y=0
StartWorld() ;Start program over again

Default ;If any other key is pressed
End ;End program
End Select
End Select
End Function
;

Function DrawMapTile() ;Declaring DrawMapTile function
TileImage DrawMapImage,x,y ;Draw whatever image is stored in DrawMapImage
;variable at coordinates x,y
;MAV occurring HERE! Image does not exist...

x=x+64 ;increment value x (horizontal) by 64 so we can control image placement

Select x ;If x reaches edge of screen - a value of 768
Case 768
y=y+64 ;increment vertical y variable by 64
x=0 ;and put x back to zero, starting us over from left to right, next row
Default ;If x equals anything other than 768
CreateWorld() ;Call CreateWorld and draw next row of images

End Select
End Function