Another small and simple but still quite fun demo example
I just made some fixes and additions to my libraries. While testing, I ported this from Inferno using my primitives module.
Any feedback is welcome...
Small and simple demo example
Re: Small and simple demo example
really nice!
Unfortunately the current Hollywood scroll problem(it was scattering) was here too...
Unfortunately the current Hollywood scroll problem(it was scattering) was here too...
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: Small and simple demo example
@Tuxedo:
Change your line in the code:
scroll = SetInterval(Nil, p_Scroll, 20)
by
SetInterval(Nil, p_Scroll, 10)
It's much nice on my PC
Change your line in the code:
scroll = SetInterval(Nil, p_Scroll, 20)
by
SetInterval(Nil, p_Scroll, 10)
It's much nice on my PC
Re: Small and simple demo example
mmm...
here no changes with that...
Always scattering...
here no changes with that...
Always scattering...
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: Small and simple demo example
Try this one (You need my Hollywood Game Framework library):
Code: Select all
@DISPLAY {Width = 640, Height = 480, Title = "Hollywood Game Framework Scroll Test"}
; Include game framework
@INCLUDE "hgf/game.hws"
; Include game states
; Include modules
; Data files
@BRUSH 1, "bg.jpg" ; Some really large picture
; Setup
Function game.load()
bg = image:new(1)
xy = point:new()
speed = 100
game:setUpdateRate(60)
EndFunction
; Draw
Function game.draw()
game.buffer:drawImg(bg.r, bg, xy)
EndFunction
; Update
Function game.update(dt)
If IsKeyDown("LEFT") Then xy.x = xy.x - speed * dt
If xy.x < 0 Then xy.x = 0
If IsKeyDown("RIGHT") Then xy.x = xy.x + speed * dt
If xy.x > bg.r:dx() - game.buffer.r:dx() Then xy.x = bg.r:dx() - game.buffer.r:dx()
If IsKeyDown("UP") Then xy.y = xy.y - speed * dt
If xy.y < 0 Then xy.y = 0
If IsKeyDown("DOWN") Then xy.y = xy.y + speed * dt
If xy.y > bg.r:dy() - game.buffer.r:dy() Then xy.y = bg.r:dy() - game.buffer.r:dy()
If IsKeyDown("ESC") Then End
EndFunction
; Go!
game:go()
Re: Small and simple demo example
Sorry, I made a small typo: drawing rectancle's size should naturally be the same as the rectangle of the drawing buffer:
Code: Select all
@DISPLAY {Width = 640, Height = 480, Title = "Hollywood Game Framework Scroll Test"}
; Include game framework
@INCLUDE "hgf/game.hws"
; Include game states
; Include modules
; Data files
@BRUSH 1, "bg.jpg" ; Some really large picture
; Setup
Function game.load()
bg = image:new(1)
xy = point:new()
speed = 100
game:setUpdateRate(60)
EndFunction
; Draw
Function game.draw()
game.buffer:drawImg(game.buffer.r, bg, xy) ; parameters: drawing rectancle, image to draw, offset point in image)
EndFunction
; Update
Function game.update(dt)
If IsKeyDown("LEFT") Then xy.x = xy.x - speed * dt
If xy.x < 0 Then xy.x = 0
If IsKeyDown("RIGHT") Then xy.x = xy.x + speed * dt
If xy.x > bg.r:dx() - game.buffer.r:dx() Then xy.x = bg.r:dx() - game.buffer.r:dx()
If IsKeyDown("UP") Then xy.y = xy.y - speed * dt
If xy.y < 0 Then xy.y = 0
If IsKeyDown("DOWN") Then xy.y = xy.y + speed * dt
If xy.y > bg.r:dy() - game.buffer.r:dy() Then xy.y = bg.r:dy() - game.buffer.r:dy()
If IsKeyDown("ESC") Then End
EndFunction
; Go!
game:go()
Re: Small and simple demo example
onestly dont seems to me so smooth...
And also the weird thing was that I cant get 100% cpu usage with my old example with double bufferig way posted somewhere here...
So a problem have to happen somewhere in the hollywood core...
And also the weird thing was that I cant get 100% cpu usage with my old example with double bufferig way posted somewhere here...
So a problem have to happen somewhere in the hollywood core...
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: Small and simple demo example
On my Windows machine, it's not too bad with small screen size (some minor flicks are still noticeable, though).Tuxedo wrote:onestly dont seems to me so smooth...
And also the weird thing was that I cant get 100% cpu usage with my old example with double bufferig way posted somewhere here...
So a problem have to happen somewhere in the hollywood core...
My scrolling example uses double buffer for drawing too and if I check ( game:getFPS() function ), framerate should not drop below 60 (it's set to 60 in the example).
If you want 100% cpu load on your scrolling code, then remove all timing from scrolling loop except VWait() call before the screen update.