Im learning BlitzPlus, and I keep getting an error "expecting end of file"
should I post my code?
Where can I get Blitz+ tutorials?
CODE FOR MAP EDITOR (incomplete)
;Platform Map editor
AppTitle "ShadowX Map Editor"
gwidth=800
gheight=600
tsize=40
numtiles=4
Timer = CreateTimer(30)
Graphics gwidth,gheight,16,2
scr_left = 0
scr_top = 0
infile = OpenFile("map1.map");Assign infile to loading the map
imgSprite = LoadImage("graphics\sprite.bmp") ;assign the variable imgSprite to loading a sprite
If infile <> 0 Then
mapx = ReadInt(infile)
mapy = ReadInt(infile)
Else
mapx = 50
mapy = 20
EndIf
Dim map$(mapx,mapy)
If infile <> 0 Then
For y = 0 To mapy-1
For x = 0 To mapx-1
map(x,y) = 0
Next
Next
EndIf
CloseFile infile
img_tiles = LoadAnimImage("Graphics\tileset.bmp") ,tsize,tsize,0,numtiles) ; Assign the variable imgTile to loading the tilesets.
seltile = 2
SetBuffer BackBuffer()
Color 0,255,255
While Not KeyHit(1)
Cls
For y = 0 To mapy
For x = 0 To mapx
tilenum = Int(map(x,y))-1
If (x*tsize)-scr_left > -tsize And (x*tsize)-scr_left < gwidth And (y*tsize)-scr_top > -tsize And (y*tsize)-scr_top < gheight Then
;draw tile
If tilenum > -1 Then DrawImage img_tiles,(x*tsize)-scr_left,(y*tsize)-scr_top,tilenum
EndIf
Next
Next
;Scrolling around map w/ keys
If KeyDown(208) And scr_top < (mapy*tsize-gheight) Then scr_top = scr_top+15
If KeyDown(205) And scr_left < (mapx*tsize-gheight Then scr_left = scr_left+15
If KeyDown(203) And scr_left > -menuwidth Then scr_left = scr_left-15
If KeyDown(200) And scr_top > 0 Then scr_top = scr_top-15
Rect (((MouseX()+scr_left)/tsize)*tsize)-scr_left-1,(((MouseY()+scr_top)/tsize)*tsize)-scr_top-1,tsize+2,tsize+2,0
If seltile > 0 DrawImage img_tiles,(((MouseX()+scr_left)/tsize)*tsize)-scr_left,(((MouseY()+scr_top)/tsize)*tsize)-scr_top,seltile-1
If MouseDown(1)
map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf
If selmouse < MouseZ() Then seltile = seltile + 1
If selmouse > MouseZ() Then seltile = seltile - 1
selmouse = MouseZ()
I'm so sorry for being a noob.
Last edited by YenTex on Sun Mar 01, 2009 11:42 pm, edited 2 times in total.
End of line errors usually mean you didn't close something off, such as an "if" statement. I'm familiar with Blitz3D, but not BlitzPlus. The only thing I noticed was this inconsistency:
If MouseDown(1)
map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf
Every other "if" statement has a "Then" at the end of the line except this one, your last in the code you posted. I'm not sure if those are necessary for multi-line "if" statements, but it's best to keep things like that consistent. Keep your code as clean as possible, and errors like this will be easier to find.
;Platform Map editor
AppTitle "ShadowX Map Editor"
gwidth=800
gheight=600
tsize=40
numtiles=4
Timer = CreateTimer(30)
Graphics gwidth,gheight,16,2
scr_left = 0
scr_top = 0
infile = OpenFile("map1.map");Assign infile to loading the map
imgSprite = LoadImage("graphics\sprite.bmp") ;assign the variable imgSprite to loading a sprite
If infile <> 0 Then
mapx = ReadInt(infile)
mapy = ReadInt(infile)
Else
mapx = 50
mapy = 20
EndIf
Dim map$(mapx,mapy)
If infile <> 0 Then
For y = 0 To mapy-1
For x = 0 To mapx-1
map(x,y) = 0
Next
Next
EndIf
CloseFile infile
img_tiles = LoadAnimImage("tileset.bmp",tsize,tsize,0,numtiles)
;LOL
;LOL
seltile = 2
SetBuffer BackBuffer()
Color 0,255,255
While Not KeyHit(1)
Cls
For y = 0 To mapy
For x = 0 To mapx
tilenum = Int(map(x,y))-1
If (x*tsize)-scr_left > -tsize And (x*tsize)-scr_left < gwidth And (y*tsize)-scr_top > -tsize And (y*tsize)-scr_top < gheight Then
;draw tile
If tilenum > -1 Then DrawImage img_tiles,(x*tsize)-scr_left,(y*tsize)-scr_top,tilenum
EndIf
Next
Next
;Scrolling around map w/ keys
If KeyDown(208) And scr_top < (mapy*tsize-gheight) Then scr_top = scr_top+15
If KeyDown(205) And scr_left < (mapx*tsize-gheight )Then scr_left = scr_left+15
If KeyDown(203) And scr_left > -menuwidth Then scr_left = scr_left-15
If KeyDown(200) And scr_top > 0 Then scr_top = scr_top-15
Rect (((MouseX()+scr_left)/tsize)*tsize)-scr_left-1,(((MouseY()+scr_top)/tsize)*tsize)-scr_top-1,tsize+2,tsize+2,0
If seltile > 0 DrawImage img_tiles,(((MouseX()+scr_left)/tsize)*tsize)-scr_left,(((MouseY()+scr_top)/tsize)*tsize)-scr_top,seltile-1
If MouseDown(1)
map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf
If selmouse < MouseZ() Then seltile = seltile + 1
If selmouse > MouseZ() Then seltile = seltile - 1
selmouse = MouseZ()
If MouseHit(2) Then seltile = seltile + 1
If seltile > numtiles Then seltile = 0
If seltile = -1 Then seltile = numtiles
;Clear map w/C key
If KeyHit(46) Then
For y = 0 To mapy-1
For x = 0 To mapx-1
map(x,y) = 0
Next
Next
EndIf
;Save with S
;------------------------
If KeyHit(31) Then
;Open outpu in write mode
fileout = WriteFile("map1.map")
WriteInt fileout,mapx
WriteInt fileout,mapy
For y = 0 To mapy-1
For x = 0 To mapx-1
WriteInt fileout,map(x,y)
Next
Next
CloseFile fileout
EndIf
Flip
Wend
EndGraphics
End
Now it says I have an invalid file stream handle
Last edited by YenTex on Sun Mar 01, 2009 11:49 pm, edited 1 time in total.
Although I nothing about the language you are using (even its name slips my mind), I would assume it's having trouble finding a file you are trying to load. Similar problems can occur in C++. If a file name or path is incorrect, for instance, then the debugger might say something like, "invalid file pointer."
EDIT: Whoops, I left off the advice: Try moving the bitmap image to different folders and see if your program starts to work.
anothrguitarist wrote:Although I nothing about the language you are using (even its name slips my mind), I would assume it's having trouble finding a file you are trying to load. Similar problems can occur in C++. If a file name or path is incorrect, for instance, then the debugger might say something like, "invalid file pointer."
EDIT: Whoops, I left off the advice: Try moving the bitmap image to different folders and see if your program starts to work.
EDIT2: Could be your map file too.
It was my map file, I can't save now for some reason.
Meh, I'll figure it out tomorrow...
Thanks for the advice
anothrguitarist wrote:Although I nothing about the language you are using (even its name slips my mind), I would assume it's having trouble finding a file you are trying to load. Similar problems can occur in C++. If a file name or path is incorrect, for instance, then the debugger might say something like, "invalid file pointer."
EDIT: Whoops, I left off the advice: Try moving the bitmap image to different folders and see if your program starts to work.
EDIT2: Could be your map file too.
It was my map file, I can't save now for some reason.
Meh, I'll figure it out tomorrow...
Thanks for the advice