Retrogamecoding and Basicprogramming Forum

Retrogamecoding(.org) => Pulsar2D => Topic started by: Roland Chastain on 14. July 2016, 19:56:23

Title: Porting a LÖVE project
Post by: Roland Chastain on 14. July 2016, 19:56:23
Hello!

I made a chessboard with LÖVE and would like to port it to Pulsar2D.

Here is where you can find the LÖVE project:
http://www.eschecs.fr/lua.html (http://www.eschecs.fr/lua.html)

I wonder how to start. I would like to get advices. In the meanwhile I begin to study Pulsar2D Lua examples.  :)

Best regards.

Roland
Title: Re: Porting a LÖVE project
Post by: Cybermonkey on 09. October 2016, 11:11:19
Sorry for writing so late. I've just recognized that we are members of many boards: https://forum.qbasic.at/, http://pascalgamedevelopment.com/forum.php and http://www.lazarusforum.de/  ;)
At the moment PulsarLua will get an update, so it uses Lua 5.3. Downloads will be soon available.
PulsarLua works differently from Löve. Löve has events, whereas PL uses one game loop. Here's the simple sprite example:

Code: [Select]
-- shows how to load an image and turn that into a sprite

require "scancodes"
knight ={}

win = openwindow ("Simple Sprite Example",-1,-1,800,600)
setactivewindow (win)
setframetimer (100)

image = loadimage ("media/sprite.bmp")
knight.image = createsprite (image)
freeimage (image)

image = loadimage ("media/grass.bmp")
grass = createsprite (image)
freeimage (image)

knight.x=windowwidth()/2
knight.y=windowheight()/2
textsize (1)
--main loop starts here:
repeat
key=getkey()
clearwindow()

if keystate (SCANCODE_RIGHT) then
knight.x=knight.x+1
end
if keystate (SCANCODE_LEFT) then
knight.x=knight.x-1
end
if keystate (SCANCODE_UP) then
knight.y=knight.y-1
end
if keystate (SCANCODE_DOWN) then
knight.y=knight.y+1
end

for i  = 0,  windowwidth(), spritewidth (grass) do
for j = 0,  windowheight(), spriteheight (grass) do
drawsprite (grass,i,j,1,1,0,false,false)
end
end

drawsprite (knight.image,knight.x,knight.y,1,1,0,false,false)

color (255,255,255,255)
texttype (1)
drawtext ("Cursor keys to move knight, ESC to quit",0,0)
texttype (2)
drawtext ("Cursor keys to move knight, ESC to quit",0,20)
sync()
until key == SCANCODE_ESCAPE
--here all comes to an end...
freesprite (knight.image)
freesprite (grass)
closewindow (win)
closeapplication()

With Lua 5.3 I would recommend changing the starting point of the sprite like this:

Code: [Select]
knight.x=int (windowwidth()/2)
knight.y=int (windowheight()/2)
Title: Re: Porting a LÖVE project
Post by: Roland Chastain on 08. November 2016, 22:47:37
Thank you for your answer.  ;)

Yes, it seems that we like the same programming languages.  :)

Glad to hear that a new version of PL is coming. Thank you for the sprite example.

As soon as I have started something, I will come back to that discussion.