Not so smooth scrolling...any help?

Discuss any general programming issues here
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Not so smooth scrolling...any help?

Post by Tuxedo »

Hi there!
I'm trying to recreate the ShadowOfTheBeast parralax scroller in Hollywood but...
I've recreated the scroller itself but it wasnt so smooth as expected...
I'm trying to compare the hollywood code against the PortablE one...
I attach the code I used if anyone would try it simply download the SOTB like scroller archive from:

http://cshandley.co.uk/portable/examples/index.html#ex5

Than simply copy the gfx and mus directories in the place you lauch the code below and look at it...
The Scrolling I created in Hollywood wasnt so smooth as in the PortablE example so...
Was something I've done wrong or was an Hollywood limitation/problem?

Thank you!

Code: Select all

@DISPLAY 1, {Title = "ShadowOfTheBeastSCroller", Color = $ffff00, MODE = "FullSCreen"}

x = 2	; varaibile che fa scorrer le immagini...la metto a 1 così al primo calcolo ha il valore giusto :)

LoadBrush(0,  "gfx/bgd1_ciel.jpg")
LoadBrush(1, "gfx/bgd2_montagnes.jpg")
LoadBrush(2, "gfx/bgd3_sol1.jpg")
LoadBrush(3, "gfx/bgd4_sol2.jpg")
LoadBrush(4, "gfx/bgd5_sol3.jpg")
LoadBrush(6, "gfx/sprite_nuages1.bmp")
LoadBrush(7, "gfx/sprite_nuages2.bmp")
LoadBrush(8, "gfx/sprite_nuages3.bmp")
LoadBrush(9, "gfx/sprite_nuages4.bmp")

OpenMusic(0, "mus/B-TITLE.MOD")

PlayMusic(0)

FOR LOCAL i = 6 TO 9 DO SetBrushTransparency(i, $000000)

BeginDoubleBuffer()

EscapeQuit(TRUE)

Function p_Scroll()

	x	= x - 2
	x2	= x2 - 3
	x3	= x3 - 4
	x4	= x4 - 5
	x6	= x6 - 6
	x7	= x7 - 5
	x8	= x8 - 4
	x9	= x9 - 3

	IF x	<= -640 THEN x = 0
	IF x2	<= -640 THEN x2 = 0
	IF x3	<= -640 THEN x3 = 0
	IF x4	<= -640 THEN x4 = 0
	IF x6	<= -640 THEN x6 = 0
	IF x7	<= -640 THEN x7 = 0
	IF x8	<= -640 THEN x8 = 0
	IF x9	<= -640 THEN x9 = 0

	DisplayBrush(0, 0, 0)	; questo è il cielo che resta fermo...

	DisplayBrushPart(1, -x, 0, 0, 199, 640 + x, 220)
	DisplayBrushPart(1, 0, 0, 640 + x, 199, -x + 1, 220)

	DisplayBrushPart(2, -x2, 0, 0, 419, 640 + x2 + 1, 10)
	DisplayBrushPart(2, 0, 0, 640 + (x2), 419, -x2 + 1, 10)

	DisplayBrushPart(3, -x3, 0, 0, 429, 640 + x3 + 1, 20)
	DisplayBrushPart(3, 0, 0, 640 + x3, 429, -x3 + 1, 20)

	DisplayBrushPart(4, -x4, 0, 0, 449, 640 + x4 + 1, 30)
	DisplayBrushPart(4, 0, 0, 640 + (x4), 449, -x4 + 1, 30)

	DisplayBrushPart(6, -x6, 0, 0, 0, 640 + x6 + 1, 82)
	DisplayBrushPart(6, 0, 0, 640 + x6, 0, -x6 + 1, 82)

	DisplayBrushPart(7, -x7, 0, 0, 83, 640 + x7 + 1, 38)
	DisplayBrushPart(7, 0, 0, 640 + x7, 83, -x7 + 1, 38)

	DisplayBrushPart(8, -x8, 0, 0, 120, 640 + x8 + 1, 18)
	DisplayBrushPart(8, 0, 0, 640 + x8, 120, -x8 + 1, 18)

	DisplayBrushPart(9, -x9, 0, 0, 138, 640 + x9 + 1, 10)
	DisplayBrushPart(9, 0, 0, 640 + x9, 138, -x9 + 1, 10)

	Flip()	; mostro cosa ho disegnato fin'ora...

EndFunction

 
Scroll	= SetInterval(Nil, p_Scroll, 1000/50)

Repeat
	WaitEvent
Forever

Simone"Tuxedo"Monsignori, Perugia, ITALY.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Not so smooth scrolling...any help?

Post by ArtBlink »

Hello tuxedo,

This is my code of multidirectional scroll

I think you can find the answer in the code ;-)

Code: Select all

@SCREEN {Mode="Ask",Width=640, Height=480, depth=16}
SetFillStyle(#FILLCOLOR)
CreateBrush (1,32,32,$000000)
SelectBrush(1)
Polygon (0,0,{32,16,0,32,0,0},3,$FF0000)
EndSelect
CreateBrush (2,32,32,$000000)
SelectBrush(2)
Box (0,0,32,32,$00AA00)
EndSelect
CreateBrush (3,32,32,$000000)
SelectBrush(3)
Box (0,0,32,32,$555555)
EndSelect
CreateBrush (4,32,32,$000000)
SelectBrush(4)
Box (0,0,32,16,$00AA00)
Box (0,16,32,32,$555555)
EndSelect
CopyBrush (4,5)
RotateBrush(5,-90)
CopyBrush (4,6)
RotateBrush(6,90)
CopyBrush (4,7)
RotateBrush(7,180)
SetBrushTransparency(1,$000000)
Dim Circuit[30][30]
Circuit[0]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
Circuit[1]={2,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2}
Circuit[2]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[3]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[4]={2,6,3,3,2,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,2,3,3,5,2}
Circuit[5]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[6]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[7]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[8]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[9]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[10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5,2}
Circuit[25]={2,6,3,3,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,3,3,5,2}
Circuit[26]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[27]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[28]={2,2,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,2,2}
Circuit[29]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
X=0
Y=0
Angle=0 
vitesse=0 
XVoiture=320
YVoiture=240
Voiture = 1
SetFontStyle(#EDGE, #BLACK, 1)

Function supercar()
	StartTimer(1)
	Flip
	
	Local Avance = IsKeyDown("UP") 
	Local Recule = IsKeyDown("Down") 
	Local Droite = IsKeyDown("RIGHT") 
	Local Gauche = IsKeyDown("LEFT")
	Local ToucheA = IsKeyDown("a")
	Local ToucheB = IsKeyDown("z")
	
	If Avance = True 
		
		
		Vitesse=vitesse+0.5
		If vitesse>6 Then vitesse=6
		Else
		If vitesse>0 Then vitesse=vitesse-0.3
		EndIf
	
	

	If Recule = True
		Vitesse=vitesse-1
		If vitesse<-3 Then vitesse=-3
	Else
		If vitesse<0 Then vitesse=vitesse+0.2

	EndIf
	
	If vitesse>0 And vitesse<0.1 Then vitesse=0
	Radians=Angle*0.01745
	If XVoiture=320 Then X=X+Cos(Radians)*vitesse
	If YVoiture=240 Then Y=Y-Sin(Radians)*vitesse
	;Blocage du scroll
	If x>320 Then X=320 
		If X=320
		XVoiture=Xvoiture+Cos(Radians)*vitesse
		If XVoiture>600 Then XVoiture=600
		If XVoiture<320 Then XVoiture=320
		EndIf
	If X<0 Then X=0
		If X=0
		XVoiture=Xvoiture+Cos(Radians)*vitesse
		If XVoiture<40 Then XVoiture=40
		If XVoiture>320 Then XVoiture=320
		EndIf

	If Y<0 Then Y=0
	If Y=0
		YVoiture=Yvoiture-Sin(Radians)*vitesse
		If YVoiture<40 Then YVoiture=40
		If YVoiture>240 Then YVoiture=240
		EndIf

	If Y>(29*32)/2 Then Y=(29*32)/2
	If Y=(29*32)/2

		YVoiture=Yvoiture-Sin(Radians)*vitesse
		If YVoiture>440 Then YVoiture=440
		If YVoiture<240 Then YVoiture=240
		EndIf

	; Si la voiture ne roule pas, elle ne tourne pas
	If vitesse<>0
		If Droite = True Then Angle=Angle-2
		If Gauche = True Then Angle=Angle+2
	EndIf
	 
	Local ViewXOffset=ViewXOffset+X
	Local ViewYOffset=ViewYOffset+Y
	If ViewXOffset<0 
		ViewXOffset=0
	Else
		If ViewXOffset>29 Then ViewXoffset=29
	EndIf
		If ViewYOffset<0 
			ViewYOffset=0
		Else
		If ViewYOffset>29 Then ViewYoffset=29
	EndIf

	scrolling()
	TextOut(0,0,"speed : ")
	TextOut(80,0,Round(Abs(vitesse*10)))
	TextOut(110,0,"Km/h")
	DisplayBrush(voiture,XVoiture,YVoiture,{AnchorX = 0.5, AnchorY = 0.5,rotate=Angle})
	Local Temps=GetTimer(1)
	TextOut (350,1,"Number of picture by second",#BLUE)
	TextOut (586,1,Round((1/Temps)*1000))
EndFunction

Function scrolling()
	
	Local TileX=Int(X/32)
	Local TileY=Int(Y/32)
	If TileX<0 Then TileX=0
	If tileX>9 Then TileX=9
	If TileY<0 Then TileY=0
	If tileY>14 Then TileY=14
	For Local RowCtr=TileY To 15+TileY
		For Local ColCtr=tileX To 20+tileX 
			Local TileNum=Circuit[RowCtr][ColCtr]
			Local TilePointX=(ColCtr*32)-X
			Local TilePointY=(RowCtr*32)-Y

			DisplayBrush(TileNum,TilePointX,TilePointY)

		Next
	Next
EndFunction

SetInterval (1,supercar,20)
BeginDoubleBuffer

Repeat
	WaitEvent
Forever
French tuto in french section later ;-), if you want, 3 code in french section with new 3D engine, Textured scroll for Beat them all game like shadow fighter or elfmania or kid chaos and how to use rotation of brush to make move.
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Re: Not so smooth scrolling...any help?

Post by Tuxedo »

Thanks for the reply.
I cant read french so cant go in the french section :P
However I cant see the real difference also you display the brush and than do a doublebuffer...
I'm worng?
Simone"Tuxedo"Monsignori, Perugia, ITALY.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Not so smooth scrolling...any help?

Post by ArtBlink »

Hello,

I make tuto in english later.

if you execute the code you understand, to know, you control red triangle, push arrow on your keyboard and you can see the scroll.

Doublebuffer can execute juste befor Repeat command or just after the first line in your code, be careful, doublebuffer command must be execute one time in your script.

If you want make scroll game, use tiles technique (table) or you programm will be too slow with screen restriction (limit of display bruh)

Try this and give me the number

Code: Select all

@DISPLAY 1, {Title = "ShadowOfTheBeastSCroller", Color = $ffff00, MODE = "FullSCreen"}

x = 2   ; varaibile che fa scorrer le immagini...la metto a 1 così al primo calcolo ha il valore giusto :)

LoadBrush(0,  "gfx/bgd1_ciel.jpg")
LoadBrush(1, "gfx/bgd2_montagnes.jpg")
LoadBrush(2, "gfx/bgd3_sol1.jpg")
LoadBrush(3, "gfx/bgd4_sol2.jpg")
LoadBrush(4, "gfx/bgd5_sol3.jpg")
LoadBrush(6, "gfx/sprite_nuages1.bmp")
LoadBrush(7, "gfx/sprite_nuages2.bmp")
LoadBrush(8, "gfx/sprite_nuages3.bmp")
LoadBrush(9, "gfx/sprite_nuages4.bmp")

OpenMusic(0, "mus/B-TITLE.MOD")

PlayMusic(0)

FOR LOCAL i = 6 TO 9 DO SetBrushTransparency(i, $000000)

BeginDoubleBuffer()

EscapeQuit(TRUE)

Function p_Scroll()
	StartTimer(1)
   x   = x - 2
   x2   = x2 - 3
   x3   = x3 - 4
   x4   = x4 - 5
   x6   = x6 - 6
   x7   = x7 - 5
   x8   = x8 - 4
   x9   = x9 - 3

   IF x   <= -640 THEN x = 0
   IF x2   <= -640 THEN x2 = 0
   IF x3   <= -640 THEN x3 = 0
   IF x4   <= -640 THEN x4 = 0
   IF x6   <= -640 THEN x6 = 0
   IF x7   <= -640 THEN x7 = 0
   IF x8   <= -640 THEN x8 = 0
   IF x9   <= -640 THEN x9 = 0

   DisplayBrush(0, 0, 0)   ; questo è il cielo che resta fermo...

   DisplayBrushPart(1, -x, 0, 0, 199, 640 + x, 220)
   DisplayBrushPart(1, 0, 0, 640 + x, 199, -x + 1, 220)

   DisplayBrushPart(2, -x2, 0, 0, 419, 640 + x2 + 1, 10)
   DisplayBrushPart(2, 0, 0, 640 + (x2), 419, -x2 + 1, 10)

   DisplayBrushPart(3, -x3, 0, 0, 429, 640 + x3 + 1, 20)
   DisplayBrushPart(3, 0, 0, 640 + x3, 429, -x3 + 1, 20)

   DisplayBrushPart(4, -x4, 0, 0, 449, 640 + x4 + 1, 30)
   DisplayBrushPart(4, 0, 0, 640 + (x4), 449, -x4 + 1, 30)

   DisplayBrushPart(6, -x6, 0, 0, 0, 640 + x6 + 1, 82)
   DisplayBrushPart(6, 0, 0, 640 + x6, 0, -x6 + 1, 82)

   DisplayBrushPart(7, -x7, 0, 0, 83, 640 + x7 + 1, 38)
   DisplayBrushPart(7, 0, 0, 640 + x7, 83, -x7 + 1, 38)

   DisplayBrushPart(8, -x8, 0, 0, 120, 640 + x8 + 1, 18)
   DisplayBrushPart(8, 0, 0, 640 + x8, 120, -x8 + 1, 18)

   DisplayBrushPart(9, -x9, 0, 0, 138, 640 + x9 + 1, 10)
   DisplayBrushPart(9, 0, 0, 640 + x9, 138, -x9 + 1, 10)

   Flip()   ; mostro cosa ho disegnato fin'ora...
Local Temps=GetTimer(1)
TextOut (350,1,"Number of picture by second")
TextOut (586,1,Round((1/Temps)*1000))
EndFunction


Scroll   = SetInterval(Nil, p_Scroll, 1000/50)

Repeat
   WaitEvent
Forever
I think the problem is the size of brush and their number
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Re: Not so smooth scrolling...any help?

Post by Tuxedo »

I get a changing number from 90 to 100...
If I decrease the screen update to 25fps the number was more readable and was many times 91 and 100 other times something like 83 but however same numbers than in 50fps...

I changed the code to:

Local Temps=GetTimer(1)
TextOut (350,1,"Number of picture by second")
TextOut (586,1,Round((1/Temps)*1000))

Flip() ; mostro cosa ho disegnato fin'ora...

since if flip was before the:

Local Temps=GetTimer(1)
TextOut (350,1,"Number of picture by second")
TextOut (586,1,Round((1/Temps)*1000))

no text was written on the screen...

That helps?
Simone"Tuxedo"Monsignori, Perugia, ITALY.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Not so smooth scrolling...any help?

Post by ArtBlink »

Have you test your engine with setinterval for displaybrushpart?

ex:

function brush1()

displaybrushpar(1,....

Endfunction

function brush2()

displaybrushpart(2,...

endfunction

etc...

setinterval(1,brush1,40)
setinterval(2,brush2,38)
etc...
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Re: Not so smooth scrolling...any help?

Post by Tuxedo »

No...
But I've tested it without the setinterval doing a Repeat...Forever loop without interval and get almost the same speed and cpu time(about 85%) also if I use a infinite loop without timing...
I've expected a 100% cpu instead of 85%...

Why to test an interval for every DisplayBrushPart()?
Simone"Tuxedo"Monsignori, Perugia, ITALY.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Not so smooth scrolling...any help?

Post by ArtBlink »

I have make speed test, I think brush is too big, if you want to create parallax scrolling, use tile technique
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Re: Not so smooth scrolling...any help?

Post by Tuxedo »

I will try but I've however to update the entire screen since the scrolling changes all the screen veery frame...
In wich way blitting many tiny tiles was easier than blitting one big tile? Wasnt slower calling DisplayBrush much times?

But probably I miss comething in my poor programming klnowledge... ?
Simone"Tuxedo"Monsignori, Perugia, ITALY.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Not so smooth scrolling...any help?

Post by ArtBlink »

Normaly, yes, blitting small tile is faster than big tile... but on Classics Amiga ;-) (gfx memory too low)

On Amiga NG, with the new technology of this day, normally, big tiles aren't problem to display it but hollywood have a strange comportement.

Displaybrush haven't good speed.

Later, i make display GFX vector and bitmap test to know what is the better technique to make game.

I have make memory access test with hollywood command and result are... strange, so i think gfx test are the same.

If you want to win some time, open 16 bit screen in full screen and not 32 bits screen (with all my engine, i win some FPS on MicroAone)
Post Reply