OK. I know this is not the kind of program NaaLaa has been created for, but I use it to test the speed of any language I try. Well, NaaLaa is doing a pretty good job here and runing this example as fast as other fast interpreters.
Code:
n = 35001
a = 10000
d = 0
k = 0
g = 0
l = 0
f = []
for x = 0 to n
f[x] = 2000
next
for c = n to 14 step -14
d = 0
for b = c to 1 step -1
d = d * b
g = b * 2 - 1
d = d + f[b] * a
f[b] = d % g
d = floor(d / g)
k = l + floor(d / a)
next
k2 = right("0000" + k, 4)
write k
l = d % a
next
EDIT: On my machine it takes about 1 min. to complete the task and this is the speed I'm expecting from an interpreted language. Python is slightly faster, while Perl being 25% faster than Python. Tcl is 10+ times slower than NaaLaa. It's worth to remember that NaaLaa runs through Wine, while Python, Perl and Tcl run natively.
Here is the Bubble Universe example. It seems that alpha element doesn't affect drawing single pixels:
Code:
set window "Bubble Universe", 512, 512
r = 6.283185307179586 / 235
mw = 512
mh = 512
hw = mw / 2
hh = mh / 2
x = 0
v = 0
u = 0
t = 0
k = rnd(190) + 64
set redraw 0
while 1
set color 0, 0, 0, 255
draw rect 0, 0, 512, 512, 1
for i = 0 to 255
for j= 0 to 255
u = sin(i + v) + sin(r * i + x)
v = cos(i + v) + cos(r * i + x)
x = u + t
set color i, j, 255 - i, k
draw pixel int(hw + u * hw * 0.4), int(hh + v * hh * 0.4)
next
next
redraw
t = t + 0.01
k = rnd(190) + 64
wend
Is this a bug? I've tried draw pixel, set pixel and even both.
Recently, I have been banned from a forum and my nickname has been added to censored words, so other users can't even mention my name. So, is it OK to talk here about other languages, projects etc.?
Sorry, I must have had a temporary brain malfunction. There is already a section for discussing other languages and programming in general.
So, I've tried to run NaaLaa 7 on Linux, but didn't have much success. NED runs, but the text is overlapping. That wouldn't be a big problem (as I use Geany with everything), but more complex examples fail to compile an run due to some .dlls missing. I'm aware that NaaLaa is Windows only and the problems have more to do with Wine than NaaLaa itself, but I wonder why much more complex applications run under Wine and NaaLaa doesn't.
Well, it has taken until 4th of February, for us to get what I call a warm Melbourne summer's day... A very nice 38C... at last... It is rare that we get hot days, 45C+, but it does happen... How warm does it get for other Forum members?
(Well, the forum IS listed as "Everything Else"... I suppose the weather would be included in that category... Moo Ha Ha Ha)
The game starts on the title screen by pressing the return key to start, the "p" key to pause, the arrow keys to move the ship and the "z" key to shoot. You have to shoot the central square of the enemies to destroy them.
This comment is for Marcus, the game has an error that I have not been able to solve because I don't know what the error is, I have left you a screenshot with the error.
The game sometimes works well and other times the error occurs, it usually happens more times when you beat the game and start a second game again, although it can also happen in the first game and there are times when it doesn't happen and you can beat the game without let nothing happen.
I don't remember if I ever posted something about the json library in the old forum - the one that crashed. But it's very easy to use and can be used for saving and loading most n7 tables. You can read more about the file format here: https://en.wikipedia.org/wiki/JSON
Code:
' json_example.n7
' ---------------
' Using the json library you can turn "any" table into a json string. You can save this string to
' file and load it again to get an exact replica of the original table. So it's a very handy library
' and file format.
include "json.n7"
' Let's say you want to save the player's progress in a game.
data = []
data.lastSaved = time()
data.score = 1349
data.name = "Marcus"
data.level = 5
data.levelScores = [1439, 5131, 1486, 394]
data.position = [x: 10, y: 15]
' Create a file for saving.
f = createfile("savedata.json")
if file(f)
' Use JSON_ToString to create a json string and write it to the file.
write file f, JSON_ToString(data)
free file f
' Use JSON_FromFile (there's also JSON_FromString) to load the data into a variable.
data = JSON_FromFile("savedata.json")
' Print out the information loaded from file.
t = datetime(data.lastSaved)
pln "lastSaved = " + t.year + "-" + str(t.month, 2) + "-" + str(t.day, 2) +
" " + str(t.hour, 2) + ":" + str(t.minute, 2) + ":" + str(t.second)
pln "score = " + data.score
pln "name = " + data.name
pln "level = " + data.level
pln "levelScores[2] = " + data.levelScores[2]
pln "position = " + data.position.x + ", " + data.position.y
else
pln "Couldn't create file!"
endif
system "pause"
Edit I wrote "most tables". You can assign functions to variabels in an n7 table, and json doesn't support that ofcourse.
While I was doing the pong I tried to create the graphics without filling and I like how it looked but the outline was too thin.
The suggestion is that a new parameter be added to the primitive graphics functions to increase the thickness of the contour, and some new functions to create other types of primitive graphics would not be bad either.