RetroBASIC
Retrogamecoding(.org) => Pulsar2D => Topic started by: Cybermonkey on August 29, 2015, 10:03:41 AM
-
... and so I am. ;)
I just wanted to let you know that I needed a time-out from programming. But now I am back and have some news for you.
Pulsar2D will be released definitely this year. What can you expect? First something you might not like: PulsarLua will not come with its own IDE, you'll have to use a third party editor like Geany or Textadept. (I will provide syntax files for them, though). Then I removed the new particle system because it slowed things down but I added the simple particles again known from EGSL.
On the other hand you will be able to make your games in three (3!) languages now: Lua, FreePascal and FreeBASIC. Yes, that's right, I just finished the port for FreeBASIC, although it needs some testing. You will also get examples for all three languages. Executables made with all three languages work fine with Windows 10.
Here comes an example, how a FreeBASIC app looks like (a simple particle example):
#include once "pulsar2d.bi"
using p2d
dim win as p2d.window
dim partsize as integer = 3
dim key as integer
dim mysprite as p2d.sprite
dim mouse as p2d.sprite
win = openwindow ("Pulsar2D in FreeBASIC",-1,-1,1366,768)
setactivewindow (win)
setvirtualsize (1366,768)
backcolor (0,0,0,255)
setframetimer (100)
hidemouse()
mysprite = loadsprite ("media/particle.png")
mouse = loadsprite ("media/bluepointer.png")
spritecolor (mysprite, 255,200,0,55)
setsimpleparticlesize (partsize,rrandom)
SetSimpleParticleImage (mysprite)
textsize (2)
do
clearwindow
key=p2d.getkey()
color (255,255,0,255)
drawtext ("Press 1-6 for particle type, press left mousbutton to draw, ESC to quit.",0,0)
if key = SDL_SCANCODE_1 then
resetsimpleparticles()
setsimpleparticletype(ptFillBox)
end if
if key = SDL_SCANCODE_2 then
resetsimpleparticles()
setsimpleparticletype(ptFillCircle)
end if
if key = SDL_SCANCODE_3 then
resetsimpleparticles()
setsimpleparticletype(ptBox)
end if
if key = SDL_SCANCODE_4 then
resetsimpleparticles()
setsimpleparticletype(ptCircle)
end if
if key = SDL_SCANCODE_5 then
resetsimpleparticles()
setsimpleparticletype(ptDot)
end if
if key = SDL_SCANCODE_6 then
resetsimpleparticles()
setsimpleparticletype(ptImage)
end if
if key= SDL_SCANCODE_F then
togglefullscreen
resizewindow (1366,768)
end if
if mousebutton()=1 then
createsimpleparticles (mousex,mousey,50,150,255,200,0,55)
end if
drawsprite (mouse,mousex,mousey,1,1,0,false,false)
updatesimpleparticles()
if mousex >= windowwidth then
warpmouse (windowwidth,mousey) 'needed for full screen
end if
if mousey >= windowheight then
warpmouse (mousex,windowheight) 'needed for full screen
end if
sync()
loop until key=SDL_SCANCODE_ESCAPE
closewindow(win)
freesprite (mysprite)
freesprite (mouse)
closeapplication()
EDIT: The new webpage will be on pulsar2d.org
-
Oh, another thing I forgot: Pulsar2D is licensed under the zlib license. so you can use the framework for any purposes even commercial ones.
-
;D Fine! Cool!
Thanks a lot in advance 8)
-
I know you're working on documentation, but could you make Pulsar available to download? The whole counting and "be patient" thing is a bit silly. You're not Apple and Pulsar isn't a new iPhone. ;)
-
Ok, the site is alive and all downloads are available. I couldn't finish anything I wanted to, because I lost a lot of time for building the webpage. Yes, the on which is now online was done fast. I first installed Joomla, but I thought it is too bulky. After that I tried Websitebaker but I got a lot of php errors. So it's just an old fashioned pandoc generated website for now. A better one will follow soon also with a finished documentation.
I am sorry for any inconvenience.
-
Nice work, Mark.
Translating from EGSL can be tricky.
The color command now has 4 numbers, instead of 3.
If you do like I did, and make the last number a 0, you will get a blank screen.
That Geany program is a trick to use. Some of those buttons on it needs to be set up and I am still working on it.
The file, filetypes.lua needs to be put in the geany data folder. That gives it plenty of color.
I don't know how, but clicking on any .lua file, runs it.
I will try later to make an EXE
-
Nice !
It was not too hard to modify some EGSL scripts, functions are nearly similar, except for few details.
@Rick3137: the 4th number in color commands corresponds to transparency (alpha channel) ; 0 is total transparency, 255 is opacity. It's very usefull.
There is just a little problem with the current window: after it had been reduced or overlapped, it does not refresh its content (whereas EGSL did).
-
Another remark (if it could help) : for same scripts, EGSL is a bit faster than Pulsar2D/PulsarLua ; there is a difference of 0.3 to 0.4 seconds (in favor of EGSL)
-
Nice !
It was not too hard to modify some EGSL scripts, functions are nearly similar, except for few details.
@Rick3137: the 4th number in color commands corresponds to transparency (alpha channel) ; 0 is total transparency, 255 is opacity. It's very usefull.
There is just a little problem with the current window: after it had been reduced or overlapped, it does not refresh its content (whereas EGSL did).
For refreshing the window you need always to do a sync().
-
Another remark (if it could help) : for same scripts, EGSL is a bit faster than Pulsar2D/PulsarLua ; there is a difference of 0.3 to 0.4 seconds (in favor of EGSL)
Do you have an example?
EDIT: I just tested the fractals.lua; see for yourself. Pulsar2D is faster (the mentioned 0.3 seconds). Do you use a hardware accelerated graphics driver?
-
I made a short program to draw a hexagon.
I did a sync(), to show it. Worked fine.
I then did a drawtext command and did another sync() to show that.
The 2nd sync() eraised the hexagon.
Is that normal?
win = openwindow ("Hexagon",-1,-1,640,480)
setactivewindow (win)
textsize(2)
backcolor (0,0,0,255)
cls()
Pi2=6.28318
Ang1 = Pi2/6 ; Ang = 0 ; x = 400.0 ; y = 400.0
color (255,0,0,255)
function RotateLeft()
Ang = Ang + Ang1
if Ang > Pi2 then
Ang = Ang - Pi2
end
end
function MoveSteps ( distance )
dx = cos(Ang) * distance
dy = sin(Ang) * distance
x2 = x + dx
y2 = y - dy
line( x,y,x2,y2)
x = x2 ; y = y2
end
color (0,0,255,255)
cnt = 0
while cnt < 6
do -- the pair of keywords " do " and " end " are like brackets in c-language
MoveSteps ( 100 )
RotateLeft()
cnt = cnt + 1
end
--sync()
drawtext("Press any key to exit ..",0,0)
sync()
key=inkey()
closewindow(win) -- This ends the program.
closeapplication()
-
There is just a little problem with the current window: after it had been reduced or overlapped, it does not refresh its content (whereas EGSL did).
For refreshing the window you need always to do a sync().
Yes, I did it: redraw() or sync(). I must express wrong (sorry for my english!) :-[
I meant the Pulsar window does not display its content again after its status has been modified, e.g. by resizing (minimizing) the window or when it has been hidden by another window.
Another remark (if it could help) : for same scripts, EGSL is a bit faster than Pulsar2D/PulsarLua ; there is a difference of 0.3 to 0.4 seconds (in favor of EGSL)
Do you have an example?
EDIT: I just tested the fractals.lua; see for yourself. Pulsar2D is faster (the mentioned 0.3 seconds). Do you use a hardware accelerated graphics driver?
:-\ Sorry again, I didn't specify the scripts I used. But it was precisely this same example, and another too.
I don't think I have a hardware accelerated graphics driver in my old computer (and I don't know how I can detect it).
However, with the last release of Löve, for instance, I noticed a real improvement (speed, etc.), in relation to its previous versions − moreover I'm not very comfortable with the “programming style” of Löve.
On the other hand, I must say that animations are at least twice faster (maybe more) with Pulsar than with EGSL. My reckonings are not accurate ; I just modified all my temporizings on the run, multiplying them (or reducing the steps) by two.
-
I made a short program to draw a hexagon.
I did a sync(), to show it. Worked fine.
I then did a drawtext command and did another sync() to show that.
The 2nd sync() eraised the hexagon.
Is that normal?
win = openwindow ("Hexagon",-1,-1,640,480)
setactivewindow (win)
textsize(2)
backcolor (0,0,0,255)
cls()
Pi2=6.28318
Ang1 = Pi2/6 ; Ang = 0 ; x = 400.0 ; y = 400.0
color (255,0,0,255)
function RotateLeft()
Ang = Ang + Ang1
if Ang > Pi2 then
Ang = Ang - Pi2
end
end
function MoveSteps ( distance )
dx = cos(Ang) * distance
dy = sin(Ang) * distance
x2 = x + dx
y2 = y - dy
line( x,y,x2,y2)
x = x2 ; y = y2
end
color (0,0,255,255)
cnt = 0
while cnt < 6
do -- the pair of keywords " do " and " end " are like brackets in c-language
MoveSteps ( 100 )
RotateLeft()
cnt = cnt + 1
end
--sync()
drawtext("Press any key to exit ..",0,0)
sync()
key=inkey()
closewindow(win) -- This ends the program.
closeapplication()
Nope, that's not normal. I tried your example with one and two syncs and it works nice here. Meaning with two syncs nothing is erased ...
-
There is just a little problem with the current window: after it had been reduced or overlapped, it does not refresh its content (whereas EGSL did).
For refreshing the window you need always to do a sync().
Yes, I did it: redraw() or sync(). I must express wrong (sorry for my english!) :-[
I meant the Pulsar window does not display its content again after its status has been modified, e.g. by resizing (minimizing) the window or when it has been hidden by another window.
Another remark (if it could help) : for same scripts, EGSL is a bit faster than Pulsar2D/PulsarLua ; there is a difference of 0.3 to 0.4 seconds (in favor of EGSL)
Do you have an example?
EDIT: I just tested the fractals.lua; see for yourself. Pulsar2D is faster (the mentioned 0.3 seconds). Do you use a hardware accelerated graphics driver?
:-\ Sorry again, I didn't specify the scripts I used. But it was precisely this same example, and another too.
I don't think I have a hardware accelerated graphics driver in my old computer (and I don't know how I can detect it).
However, with the last release of Löve, for instance, I noticed a real improvement (speed, etc.), in relation to its previous versions − moreover I'm not very comfortable with the “programming style” of Löve.
On the other hand, I must say that animations are at least twice faster (maybe more) with Pulsar than with EGSL. My reckonings are not accurate ; I just modified all my temporizings on the run, multiplying them (or reducing the steps) by two.
Animations are using now a "real" timer, in EGSL it was just a counter...
Anyway, it shouldn't be possible to resize the windows with your mouse, at least it isn't possible on my systems (Linux Mint, Xubuntu, Windows 7 and Windows 10).
It can be if the window isn't refreshed anymore and waiting for a keypress or such that the content isn't visible anymore. This shouldn't happen using a game loop where the content is refreshed a few times per second. Is it possible for you to make a screencast video?
-
Anyway, it shouldn't be possible to resize the windows with your mouse, at least it isn't possible on my systems (Linux Mint, Xubuntu, Windows 7 and Windows 10).
I am on Lubuntu 14.04, and it is possible to reduce (minimize in the application bar) a Pulsar window or to hide it with another one during an animation. And of course, the Pulsar window does refresh itself thanks to the animation loop.
It can be if the window isn't refreshed anymore and waiting for a keypress or such that the content isn't visible anymore.
Indeed, but in this case, with EGSL we could recover the window and its content nevertheless, with no need to run the script again.
Concerning the script which runs faster on EGSL than on Pulsar, here is my script (with the results at the end).
It may be that I was mistaken somewhere :
local bx,by,bw,bh
bx=0
by=0
bw=256*2
bh=256*2
local sx,sy,sw,sh
sx=-2.2
sy=-1.7
sw=3.4
sh=3.4
local clock = os.clock
local temps, t0, t1
local gx, gy, zx, zy, nzx
local col,r,v,b
local x, y, c
local fen = openwindow("Mandel simple (Pulsar2D)", 50, 50, bw,bh)
setactivewindow(fen)
backcolor(0,0,0,255)
clearwindow()
sync()
t0=clock()
for x=0,bw do
for y=0,bh do
gx=x/bw*sw+sx
gy=y/bh*sh+sy
zx=gx
zy=gy
for c=0,255 do
col = c
nzx=zx*zx - zy*zy + gx
zy=2*zx*zy+gy
zx=nzx
if zx*zx + zy*zy > 4 then
col = c
break
end
end
r = col
v = col*32
b = col*64
color(r,v,b,255)
dot(x,y)
end
end
t1=clock()
temps = (t1-t0)
text = tostring(temps).." secondes."
color(255,255,0,255)
drawtext(text, 2, 2)
sync()
inkey()
closewindow(fen)
closeapplication()
-- EGSL : 2.978096 sec.
-- Pulsar : 3.359697 sec.
-- diff. = 0.381601 sec.
Other information : the problem reported by Rick3137 does not happen on my computer...
-
Anyway, it shouldn't be possible to resize the windows with your mouse, at least it isn't possible on my systems (Linux Mint, Xubuntu, Windows 7 and Windows 10).
I am on Lubuntu 14.04, and it is possible to reduce (minimize in the application bar) a Pulsar window or to hide it with another one during an animation. And of course, the Pulsar window does refresh itself thanks to the animation loop.
It can be if the window isn't refreshed anymore and waiting for a keypress or such that the content isn't visible anymore.
Indeed, but in this case, with EGSL we could recover the window and its content nevertheless, with no need to run the script again.
Concerning the script which runs faster on EGSL than on Pulsar, here is my script (with the results at the end).
It may be that I was mistaken somewhere :
local bx,by,bw,bh
bx=0
by=0
bw=256*2
bh=256*2
local sx,sy,sw,sh
sx=-2.2
sy=-1.7
sw=3.4
sh=3.4
local clock = os.clock
local temps, t0, t1
local gx, gy, zx, zy, nzx
local col,r,v,b
local x, y, c
local fen = openwindow("Mandel simple (Pulsar2D)", 50, 50, bw,bh)
setactivewindow(fen)
backcolor(0,0,0,255)
clearwindow()
sync()
t0=clock()
for x=0,bw do
for y=0,bh do
gx=x/bw*sw+sx
gy=y/bh*sh+sy
zx=gx
zy=gy
for c=0,255 do
col = c
nzx=zx*zx - zy*zy + gx
zy=2*zx*zy+gy
zx=nzx
if zx*zx + zy*zy > 4 then
col = c
break
end
end
r = col
v = col*32
b = col*64
color(r,v,b,255)
dot(x,y)
end
end
t1=clock()
temps = (t1-t0)
text = tostring(temps).." secondes."
color(255,255,0,255)
drawtext(text, 2, 2)
sync()
inkey()
closewindow(fen)
closeapplication()
-- EGSL : 2.978096 sec.
-- Pulsar : 3.359697 sec.
-- diff. = 0.381601 sec.
Other information : the problem reported by Rick3137 does not happen on my computer...
Hm, I can put a window in front of a Pulsar window (finished script, and no sync anymore) and the content is still present. Also if I minimize it to the taskbar and get it back, the content is also present.
Your script is interesting, here the EGSL version is also slightly faster. It practically is the same I used, only that I did a redraw at the end of the second loop. And then Pulsar is faster. Well, actually the Lua part is exactly the same, on Windows it's even the same DLL. So the difference lies between SDL and SDL2, I guess.
-
My Windows 8.1 has a similar redraw problem. If I minimize a pulsar window to the taskbar, everything is missing when I bring it back. On the other hand, covering the window with another one, does not hurt it.
-
Well, actually the Lua part is exactly the same, on Windows it's even the same DLL. So the difference lies between SDL and SDL2, I guess.
It's what I guessed too, but I was not sure (because I'm not really a skilled programmer).
Maybe both problems (speed of script and “window refreshing”) are then linked (?)
P.S.: the version of my SDL2 is 2.0.2
adding :
With the loop in this modified script, there is no more problem for displaying the window again (after reducing it or after hiding it) :
local bx,by,bw,bh
bx=0
by=0
bw=256*2
bh=256*2
local sx,sy,sw,sh
sx=-2.2
sy=-1.7
sw=3.4
sh=3.4
local clock = os.clock
local temps, t0, t1
local gx, gy, zx, zy, nzx
local col,r,v,b
local x, y, c
fen1 = openwindow("Mandel simple (Pulsar2D)", -1, -1, bw,bh)
setactivewindow(fen1)
backcolor(0,0,0,255)
clearwindow()
redraw()
t0=clock()
for x=0,bw do
for y=0,bh do
gx=x/bw*sw+sx
gy=y/bh*sh+sy
zx=gx
zy=gy
for c=0,255 do
col = c
nzx=zx*zx - zy*zy + gx
zy=2*zx*zy+gy
zx=nzx
if zx*zx + zy*zy > 4 then
col = c
break
end
end
r = col
v = col*32
b = col*64
color(r,v,b,255)
dot(x,y)
end
end
t1=clock()
temps = (t1-t0)
text = tostring(temps).." secondes."
color(255,255,0,255)
drawtext(text, 2, 2)
--redraw()
--LOOP----------------------
repeat
redraw()
until getkey() == 41 --> <esc>
----------------------------
closewindow(fen1)
closeapplication()
-
I have been using several dialects of Basic and forgot all about the "local" command found in functions.
My programs do really strange things if I forget to declare variables local.
Not really a bug, but it can sure look like one.
-
Erm, instead of
--LOOP----------------------
repeat
redraw()
until getkey() == 41
----------------------------
better use
--LOOP----------------------
repeat
sync()
until getkey() == 41
----------------------------
otherwise your CPU will go up on 100% while the loop runs. Actually you could even add a wait(20) behind sync().
-
Erm, instead of
--LOOP----------------------
repeat
redraw()
until getkey() == 41
----------------------------
better use
--LOOP----------------------
repeat
sync()
until getkey() == 41
----------------------------
otherwise your CPU will go up on 100% while the loop runs. Actually you could even add a wait(20) behind sync().
Yes, I've just realized it now (before I read your post).
Thank you :)
-
This last fix makes my Windows 8.1 flicker badly.
I must have my computer set up different than everyone else.
Maybe someday, I'll upgrade to Windows10 or Ubuntu and fix this stuff.
-
This combination of commands actually make my screen stable, but I still can't push it to the task bar:
sync()
repeat
redraw()
wait(0)
sync()
wait(100)
until getkey() == 41
closewindow(win)
closeapplication()
Changing the numbers will cause the flicker to return.
Big mystery to me.
-
This combination of commands actually make my screen stable, but I still can't push it to the task bar:
sync()
repeat
redraw()
wait(0)
sync()
wait(100)
until getkey() == 41
closewindow(win)
closeapplication()
Changing the numbers will cause the flicker to return.
Big mystery to me.
That's a mystery to me, too. Do you have hardware accelerated graphics?
On the other hand, if one minimizes a program to the taskbar it's probably a running game. No one has a window with a static content opened longer than a few seconds/minutes. Pulsar2D is intended for games, i.e for "the action", not for static content. ;)
-
The fix to my problem, is to always have a loop running. then I can always put it on the taskbar and bring it back.
The following code does the trick:
require "scancodes"
win = openwindow ("Start",-1,-1,1200,700)
setactivewindow (win)
backcolor (0,0,0,255)
repeat
cls()
key = getkey()
t1 = timerticks()
-- x,y,radius
color (255,0,250,255)
circle(500,350,300)
a = 0 ; x = 250 ; y = 200
while( a < 100200)
do
dot(x,y)
a = a + 1
x = x + 1
if x > 750 then
y = y + 1 ; x = 250
end
end
t2 = timerticks()
t3 = t2-t1
color (255,255,0,255)
textsize (2)
drawtext ("Press Escape to exit ..",0,0)
drawtext ( t3,0,20)
sync()
--key=inkey()
until key == SCANCODE_ESCAPE
closewindow(win)
closeapplication()
-
Hello!
@Cybermonkey
Congratulations for your work. I love this project! I tested successfully (under Windows 10) the FreeBASIC and the Lua examples. For the Free Pascal examples, I need SDL2 unit and don't know where to find it. I tried one that I have found somewhere but it seems it wasn't the good one. Anyway, I will follow the development of the project with interest and will certainly use it.
What is exactly the difference between "Pulsar2D" and "PulsarLua"? I would say that Pulsar2D is a library, usable with different compilers, and PulsarLua is an interpreter based on Pulsar2D. Is it correct?
Good continuation! ;)
-
Thanks, and yes, Pulsar2D is the name for the framework, whereas PulsarLua is the Lua interpreter which uses Pulsar2D. ;)
With the next release (coming soon - with the new built-in font) I will add a readme for Pascal, how to compile and where to find the SDL2 headers.
Here is the link to the github project: https://github.com/ev1313/Pascal-SDL-2-Headers
Compile PulsarLua or any example like this:
fpc example.pas -Sd
-
Works perfectly. Thank you. :)
-
Not very important, but here the PulsarLua window has no icon. It's the Win32 binary downloaded on this page:
http://pulsar2d.org/
In Windows Explorer no problem.
-
Oh, this is because you have to/can set it yourself within the script/program. Load an image with image=loadimage("blabla.png") and use seticon (image).
-
Oh, this is because you have to/can set it yourself within the script/program. Load an image with image=loadimage("blabla.png") and use seticon (image).
Perfect! Thank you.
-
windows version dont have code editor
i ask why?
why you simply not modify already EGSL editor for work with this lua translator?
-
windows version dont have code editor
i ask why?
why you simply not modify already EGSL editor for work with this lua translator?
PulsarLua has no editor anymore. Peolple didn't like the one shipped with EGSL and I have no time to code a new one. I want to concentrate on the engine/framework not on editors. As most users I use now Geany on both Windows and Linux (a syntax highlighting file is part of the download).
-
ok i will modify my own and try to run those examples
-
ok i will modify my own and try to run those examples
To run the examples on Windows, you can simply drag and drop them on pulsarlua.exe.
Aurel, why don't you want to try Geany? It has excellent Lua support (syntax highlighting, functions listing, code folding). Just replace default filetypes.lua with the file included in PulsarLua folder. It is located in path_to_Geny/data/. Then set the build commands (Build/Build Commands in the menu) for .lua files. Geany is the only serious multi language editor that comes with support for BASIC (FreeBASIC). And it works great. It's stable, fast, simple and free.
-
I simply don't like this editor and i hate one editor for everything .
also i remove this thing from SliTaz box also remove stupid Midori browser.
-
Aurel,
you are never self-fulfilled, always mortifying :P
geany is as good as gold ! why is everthing bad and stupid, come back on carpet.
-
Peter
no...Geany is not a gold it is just a code editor pushed everywhere
use Geany for this use Geany for that i hate that things.
Notepad++ is a good editor for windows/ on linux situation sucks/
but who care i will use what i like :P
-
windows version dont have code editor
i ask why?
why you simply not modify already EGSL editor for work with this lua translator?
PulsarLua has no editor anymore. Peolple didn't like the one shipped with EGSL and I have no time to code a new one. I want to concentrate on the engine/framework not on editors. As most users I use now Geany on both Windows and Linux (a syntax highlighting file is part of the download).
Well, I'm no expert but I like the EGSL editor - nice and simple.
I would have preferred Pulsar2D to have a similar built-in editor too, all included within a simple download...but I like EGSL and so haven't been tempted to try Pulsar2D yet; although the possibility of using FreePascal is tempting...but not tempting enough just yet when I think of the probable frustration and wasted hours trying to build Pulsar2D and linking it to Geany....I can feel it now... :)