do others have problems compiling this code?

BlitzMax Forums/BlitzMax Beginners Area/do others have problems compiling this code?

Bremer(Posted 2005) [#1]
I have written this vertical bitmap scroller based on one I did for the regular blitz and it compiles just fine for me, but someone posted on my website forum, that it gives the following error:

"Expecting expression but encountered Type"
and something like "v_scroll.bmx;3;42"

Could some of you please try this out and let me know if you are having problems compiling the code as well.

Graphics 640,480,0

font = LoadAnimImage( "font2.png", 18, 18, 0, 96 )

Global upScrollList:TList = CreateList()
Type upScrollText
Field txt$
Field yposition
Method New()
ListAddLast upScrollList,Self
End Method
End Type

upScrollTextFontHeight = 18
upScrollTextFontWidth = 18
upScrollCentered = True
upScrollUpdateFreq = 25
upScrollStep = 2
upScrollReset = 480 + upScrollTextFontHeight
RestoreData upScrollMessage
While txt$ <> "*"
ReadData txt$
If txt$ <> "*" Then
ct:upScrollText = New upScrollText
ct.txt$ = txt$
ct.yposition = upScrollReset
upScrollReset = upScrollReset + upScrollTextFontHeight
End If
Wend

While Not KeyHit(KEY_ESCAPE)

Cls
For ct = EachIn upScrollList
	If upScrollCentered Then
		offset = 320 - ( Len( ct.txt$ ) * upScrollTextFontWidth ) / 2
	Else
		offset = 0
	End If
	For i = 0 To Len( ct.txt$ )-1
		char = Asc( Mid( ct.txt$, i+1, 1 ) ) - 32
		DrawImage font, offset + i * 18, ct.yposition, char
	Next
Next

If MilliSecs() > lastUpScrollUpdate + upScrollUpdateFreq Then
lastUpScrollUpdate = MilliSecs()
For ct = EachIn upScrollList
ct.yposition = ct.yposition - upScrollStep
If ct.yposition < -upScrollTextFontHeight Then ct.yposition = ct.yposition + upScrollReset
Next
End If

Flip

Wend
End

#upScrollMessage
DefData ""
DefData ""
DefData "STAR WARS"
DefData ""
DefData "EPISODE IV: A NEW HOPE"
DefData ""
DefData ""
DefData ""
DefData "It is a period of civil war."
DefData "Rebel spaceships, striking"
DefData "from a hidden base have won"
DefData "their first victory against"
DefData "the evil Galactic Empire."
DefData ""
DefData ""
DefData "During the battle, Rebel spies"
DefData "managed to steal secret plans"
DefData "to the Empire's ultimate weapon,"
DefData "the Death Star, an armoured"
DefData "space station with enough power"
DefData "to destroy an entire planet."
DefData ""
DefData ""
DefData "Pursued by the Empire's sinister"
DefData "agents, Princess Leia races home"
DefData "aboard her starship, custodian"
DefData "of the stolen plans that can"
DefData "save her people and restore"
DefData "freedom to the galaxy..."
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData ""
DefData "*"


You will need this image:



Thanks,


Perturbatio(Posted 2005) [#2]
compiles and runs fine.


TeaVirus(Posted 2005) [#3]
Works for me.


rod54(Posted 2005) [#4]
Is it possible instead of going through all the motions of moving the text to just create a large screen image and scroll the graphics image by changing a pointer to where graphics memmory starts then increment the pointer a graphic line at a time. Seems like it would be faster/smoother . Is this possible in blitz max ??


Bremer(Posted 2005) [#5]

Is it possible instead of going through all the motions of moving the text to just create a large screen image and scroll the graphics image by changing a pointer to where graphics memmory starts then increment the pointer a graphic line at a time. Seems like it would be faster/smoother . Is this possible in blitz max ??



Yes that should be possible. Just make a long image, draw the text onto it, and then use drawimage with y coords that goes into minus, it will only draw whats actually within the screen area anyways so it would look as if the text is scrolling up. But not all graphic cards likes huge images, so it might be better to do it similar to this.

Alternatively you could make a series of images the width of the screen and the height of the font and then draw all the lines of text into those, and that way you would only have to draw each image for each line on the screen and not draw each letter of each line each update.

There are many ways of doing this, and the reason I am asking if others were having problems with this particular one is that someone had asked me why it wouldn't compile on his computer. But everyone else that have compiled it so far says its working, so it must be something on his computer.


DannyD(Posted 2005) [#6]
Works fine here.However I can't compile the other examples on your webpage. You are using ; as the start of a comment. Should be ' in blitzmax right ?


Bremer(Posted 2005) [#7]
If you notice, then all the top ones are for blitzPlus and Blitz3d. I have only written one example for Bmax so far. I will try it a little more clear what language they can be used with.

I think that a lot of them could be re-written to Bmax without too much trouble though.


BlitzSupport(Posted 2005) [#8]
Fine here. Ask them to post their copy of the code, in case something minor has been accidentally changed.

BTW I'd stick a FlushMem in your main loop, eg. before Flip, as you'll need it for bigger stuff (or really long scrollers!).


Bremer(Posted 2005) [#9]
BTW I'd stick a FlushMem in your main loop, eg. before Flip, as you'll need it for bigger stuff (or really long scrollers!).


Yes that would be an idea, so I have just updated the code. But as far as testing this, I think we don't have to anymore, as its only one person who have had problems with the code, and it must be something with his setup.


DannyD(Posted 2005) [#10]
I didn't realise that only 1 was blitzmax , I thought all the ones on the right hand side were. It would be great if you could convert all the nice demo examples into Max ! :)


Bremer(Posted 2005) [#11]
I will try and write one every now and then when I am not as busy as right now :) But my plan was to keep these coming, so there should be something on its way.