Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 182
» Latest member: Cellulo
» Forum threads: 114
» Forum posts: 623

Full Statistics

Online Users
There are currently 3 online users.
» 0 Member(s) | 3 Guest(s)

Latest Threads
Windows version 1.0.4 rel...
Forum: Announcements
Last Post: Rick3137
6 hours ago
» Replies: 7
» Views: 1,245
TD editor question
Forum: Questions and discussions
Last Post: Cellulo
7 hours ago
» Replies: 0
» Views: 27
Space Pooper and Pat
Forum: Showcase
Last Post: Aurel
Today, 05:53 AM
» Replies: 3
» Views: 699
Version 1.0.3 released
Forum: Announcements
Last Post: Aurel
Yesterday, 06:34 PM
» Replies: 2
» Views: 807
picking sticks in naalaa ...
Forum: Showcase
Last Post: Marcus
03-26-2019, 08:28 AM
» Replies: 9
» Views: 578
sprite sheet generator
Forum: Showcase
Last Post: Marcus
03-25-2019, 07:32 AM
» Replies: 0
» Views: 975
Zombie Tumult (GLOOM game...
Forum: Showcase
Last Post: Marcus
03-24-2019, 02:54 PM
» Replies: 1
» Views: 1,077
runtime error line 1 if l...
Forum: Bugs and suggestions
Last Post: Marcus
03-23-2019, 03:53 PM
» Replies: 1
» Views: 265
[help] how to debug var a...
Forum: Questions and discussions
Last Post: Marcus
03-23-2019, 03:12 PM
» Replies: 6
» Views: 2,112
array has not been initia...
Forum: Bugs and suggestions
Last Post: Marcus
03-23-2019, 12:35 PM
» Replies: 3
» Views: 652

 
  TD editor question
Posted by: Cellulo - 7 hours ago - Forum: Questions and discussions - No Replies

TD editor is still usable in the last version of Naalaa  ? or there is a new version released ?

Before i was on the old forum, i just register on the new forum, it's cool Naalaa is not dead.

Recently i have updated my french version of Naalaa with all tools also in french to match the last Naalaa version, also i  saved some examples from the old forum i need to sort them.

Print this item

  Space Pooper and Pat
Posted by: Marcus - 03-26-2019, 08:32 AM - Forum: Showcase - Replies (3)

Here are two, old and half finished games by John.










Attached Files
.zip   space_pooper.zip (Size: 519.29 KB / Downloads: 4)
.zip   pat.zip (Size: 131.08 KB / Downloads: 4)
Print this item

  sprite sheet generator
Posted by: Marcus - 03-25-2019, 07:32 AM - Forum: Showcase - No Replies

Here's a little tool that is not of much use when you're making games with naalaa.

When you make games that use opengl/opengles you know that texture binding can be costy. Therefor you want to squeeze as many images as possible into every texture. There are already nice tools out there that do this for you, such as Texture Packer (costs Money though). But I prefer writing my own tools, so here's a naalaa program that grabs every png image in a directory and packs them in a single image. It also generates a json file (in the same format as Texture Packer and most other programs) that specifies the locations of all sub images in the resulting image.

This program should be run from the command line. The syntax is:

atlasgen <path to images> <texture width> <texture height> [<output filename>]

So if you have a bunch of png files in a folder, c:\hello\images, and you want to generate a texture and json named my_texture.png and my_texture.json, you'd write:

Code:
atlasgen c:\hello\images 1024 1024 my_texture



Code:
' ==============================================================================
' image atlas generator, by marcus.
' ==============================================================================

import "QuickSort.lib"

LENGTH = 1
AREA = 2

if sizeof(args) < 4
   _Error "atlasgen <path to images> <atlas width> <atlas height> [(name)]"
endif

path$ = args[1]
WIDTH = int(args[2])
HEIGHT = int(args[3])

if sizeof(args) > 4
   name$ = args[4]
else
   name$ = "assets"
endif

if not (mid(path, len(path) - 1) = "/" or mid(path, len(path) - 1) = "\")
   path = path + "/"
endif
files$[] = ListFiles(path)

count = 0
for i = 0 to sizeof(files) - 1
   if len(files[i])
       load image count, path + files[i]
       if image(count) then count = count + 1
   endif
next

if count = 0 then end

' area seems to work better
sort = AREA

uns?[count]
org?[count]
rects?[1000]

tmp[count][2]
for i = 0 to sizeof(org) - 1
   ' Add spacing.
   uns[i].w = width(i) + 2
   uns[i].h = height(i) + 2
   uns[i].img = i
   uns[i].fn$ = files[i]
   tmp[i][0] = i
 ' sort based on area
   if sort = AREA
       ' This one wins in all cases.
       tmp[i][1] = uns[i].w*uns[i].h
       tmp[i][1] = tmp[i][1]*min(uns[i].w, uns[i].h)/max(uns[i].w, uns[i].h)
 ' sort based on max of width and height
   elseif sort = LENGTH
       tmp[i][1] = max(uns[i].w, uns[i].h)
   endif
next

' sort by area
_QuickSort2D tmp, 1

for i = 0 to sizeof(uns) - 1
   org[sizeof(org) - 1 - i] = uns[tmp[i][0]]
next

rectCount = 1
rects[0].x = 0
rects[0].y = 0
rects[0].w = WIDTH
rects[0].h = HEIGHT

for i = 0 to sizeof(org) - 1
   smallestIndex = rectCount
   smallestArea = WIDTH*HEIGHT*2
   for j = 0 to rectCount - 1
       if rects[j].w >= org[i].w and rects[j].h >= org[i].h and rects[j].w*rects[j].h < smallestArea
           smallestIndex = j
           smallestArea = rects[j].w*rects[j].h
       endif
   next
   if smallestIndex = rectCount
       set color 0, 0, 0
       draw rect 0, 0, 208, 24, true
       set color 255, 255, 255
       _Error "Images did not fit"
   endif

   j = smallestIndex
   org[i].x = rects[j].x
   org[i].y = rects[j].y
   orgX = rects[j].x
   orgY = rects[j].y
   orgW = rects[j].w
   orgH = rects[j].h

   rects[rectCount].x = orgX + org[i].w
   rects[rectCount].y = orgY
   rects[rectCount].w = orgW - org[i].w
   rects[rectCount].h = orgH
   a1 = rects[rectCount].w*rects[rectCount].h

   rects[rectCount].x = orgX
   rects[rectCount].y = orgY + org[i].h
   rects[rectCount].w = orgW
   rects[rectCount].h = orgH - org[i].h
   a2 = rects[rectCount].w*rects[rectCount].h

   ' This is not right. Checking which split yields one largest rectangle.
 ' It would be better to check which one yields the two 'most square' rectangles.
   if a1 > a2
       rects[j].x = orgX
       rects[j].y = orgY + org[i].h
       rects[j].w = org[i].w
       rects[j].h = orgH - org[i].h

       rects[rectCount].x = orgX + org[i].w
       rects[rectCount].y = orgY
       rects[rectCount].w = orgW - org[i].w
       rects[rectCount].h = orgH
   else
       rects[j].x = orgX + org[i].w
       rects[j].y = orgY
       rects[j].w = orgW - org[i].w
       rects[j].h = org[i].h

       rects[rectCount].x = orgX
       rects[rectCount].y = orgY + org[i].h
       rects[rectCount].w = orgW
       rects[rectCount].h = orgH - org[i].h
   endif

   rectCount = rectCount + 1
next

create image -1, WIDTH, HEIGHT
set image -1
set color 0, 0, 0, 0
for y = 0 to HEIGHT - 1
   for x = 0 to WIDTH - 1
       set pixel x, y
   next
next

for i = 0 to sizeof(org) - 1
   for y = 0 to height(org[i].img) - 1
       for x = 0 to width(org[i].img) - 1
           set image org[i].img
           c[] = pixel(x, y)
           set image -1
           set color c[0], c[1], c[2], c[3]
           set pixel org[i].x + 1 + x, org[i].y + 1 + y
       next
   next
next
save image - 1, name + ".png"

tab$ = chr(9)
create file 0, name + ".json"
wln file 0, "{", quoted("frames"), ": ["
for i = 0 to sizeof(org) - 1
   wln file 0, "{"
   wln file 0, tab, quoted("filename"), ": ", quoted(org[i].fn$), ","
   write file 0, tab, quoted("frame"), ": {"
   write file 0, quoted("x"), ": ", org[i].x + 1, ", "
   write file 0, quoted("y"), ": ", org[i].y + 1, ", "
   write file 0, quoted("w"), ": ", width(org[i].img), ", "
   wln file 0, quoted("h"), ": ", height(org[i].img), "},"
   wln file 0, tab, quoted("rotated"), ": false,"
   wln file 0, tab, quoted("trimmed"), ": false,"
   write file 0, tab, quoted("spriteSourceSize"), ": {"
   write file 0, quoted("x"), ": 0, "
   write file 0, quoted("y"), ": 0, "
   write file 0, quoted("w"), ": ", width(org[i].img), ", "
   wln file 0, quoted("h"), ": ", height(org[i].img), "},"
   write file 0, tab, quoted("sourceSize"), ": {"
   write file 0, quoted("w"), ": ", width(org[i].img), ", "
   wln file 0, quoted("h"), ": ", height(org[i].img), "}"  
   if i < sizeof(org) - 1
       wln file 0, "},"
   else
       wln file 0, "}"
   endif
next
wln file 0, "]}"
free file 0

function quoted$(txt$)
   return chr(34) + txt + chr(34)
endfunc

procedure Error(txt$)
   set color 0, 0, 0
   cls
   set color 255, 255, 255
   set caret 0, 0
   wln txt
   t = time()
   while time() < t + 2000
       redraw
       wait 10
   wend    
   end
endproc

procedure ListFiles$[](dir$)
    shellexecute "open", "cmd", "", "/c cd " + chr(34) + dir + chr(34) + " & dir /b *.png > png_list.txt", true    
    open file 0, dir + "png_list.txt"
    if file(0)
        tmp$ = ""
        while not eof(0)
            tmp = tmp + read$(0) + chr(10)
        wend
        free file 0
        return split(tmp, chr(10))
    else
        bad$[]
        return bad
    endif
endproc



Attached Files
.txt   atlasgen.txt (Size: 5.81 KB / Downloads: 1)
Print this item

  Zombie Tumult (GLOOM game)
Posted by: Marcus - 03-24-2019, 11:57 AM - Forum: Showcase - Replies (1)

I can't remember if I ever posted this (attached) half-finished game on the old forum. I made it while writing the GLOOM library. Here's a video of it:






I just tried it on my new computer and noticed that the mouse control was terrible. It seems that the set mouse <x>, <y> still has some issues. I tried to fix it within the game by waiting for 16ms after making the call, but if you're having trouble using the mouse controls you can play it with keyboard only too (click on How to play in the main menu).



Attached Files
.zip   zombie_tumult.zip (Size: 440.68 KB / Downloads: 3)
Print this item

  Windows version 1.0.4 released
Posted by: Marcus - 03-23-2019, 03:00 PM - Forum: Announcements - Replies (7)

This is just a minor bug fix.

Objects

Objects can now properly be assigned to object array references in functions. Earlier, a function like the one below would cause a runtime error:

Code:
procedure assign(&objects?[], object?)
  objects[0] = object
endproc


System
For some reason, the system command did absolutely nothing on Windows (although the undocumented shellexecute did), but it's functioning now.

Code:
system "dir & echo hello world & pause"

If you want to capture the output, I suggest you pipe it to a file and read it from there for now:

Code:
' Get a list of files in the current directory.
system "dir /b > temp.txt"
open file 0, "temp.txt"
...


Mouse

set mouse <x>, <y> was a bit bugged but has been fixed now. After calling the command, the mousex() and mousey() functions would return incorrect values until the user moved the mouse and new coordinates were registered.

Print this item

  runtime error line 1 if lib
Posted by: rolen - 02-06-2019, 10:31 PM - Forum: Bugs and suggestions - Replies (1)

when a runtime error happens inside a lib it only tells there's an error on line 1.

this makes developing a multi-file project a problem.

you need to be very careful with a lot of code or else you won't be able to find the problem.

Print this item

  [help] how to debug var arr values?
Posted by: rolen - 02-06-2019, 09:22 PM - Forum: Questions and discussions - Replies (6)

how do you check an object/variable/array value?

as far as I know, naalaa doesn't have console log function.

naalaa gui lib doesn't have a one line alert/popup i can put vals in.

how do I do that (debug values).
 
it's becoming hard to develop without being able to check these things.

please help.

Print this item

  console log for debug
Posted by: rolen - 02-01-2019, 05:27 PM - Forum: Bugs and suggestions - No Replies

it's very hard for me to check variables values etc without it.

this is a feature that would really help me in development in naalaa.

if it exists I would love to learn about it.

also is theres a one line dialog popup? that can be an alternetive.

javascript has alert() java swing also has one line dialogs.

Print this item

  run problems
Posted by: th3ch33z1t - 02-01-2019, 12:42 AM - Forum: Bugs and suggestions - Replies (3)

when i try to test my game out I save it then go to run it and it will flash up then disappear. it makes the game but doesn't run it. any ideas as to why?
Huh Confused Huh

Print this item

Bug array has not been initialized error for no apparent reason [solved]
Posted by: rolen - 01-30-2019, 05:43 PM - Forum: Bugs and suggestions - Replies (3)

I ran into this problem for a second time, i want to init an object using a function instead of writing alot of attributes.
and I get this error



this  code recreates the problem in a simplified way:

Code:
items?[5]

rem this works fine
items[0] = createItem(1,2)
rem this dosnt work
c = createItems(items)


rem create objects
function createItems(&its?[])

    for i=0  to sizeof(its)-1
        rem this line returns error
        b? = createItem(1,2)
        its[i] = b

    rem
    next

endfunc

rem create object
function createItem?(x,y)

    i?
    i.x=x
    i.y=y
    return i
endfunc


wait keydown

hacked my way out of this one myself (if anyone has a better way ill be glad to see it).

I leave this as a future reference.

the solution:

Code:
items?[5]


rem now it works
items?[] = createItems(5)


rem create objects
function createItems?[](objnum)
    its?[objnum]
    for i=0  to sizeof(its)-1
        b? = createItem(1,2)
        its[i] = b

    rem
    next
    return its
endfunc

rem create object
function createItem?(x,y)

    i?
    i.x=x
    i.y=y
    return i
endfunc


wait keydown

Print this item