Retrogamecoding(.org) > Pulsar2D

Porting a LÖVE project

(1/1)

Roland Chastain:
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

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

Best regards.

Roland

Cybermonkey:
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: ----- 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()

--- End code ---

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


--- Code: ---knight.x=int (windowwidth()/2)
knight.y=int (windowheight()/2)

--- End code ---

Roland Chastain:
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.

Navigation

[0] Message Index

Go to full version