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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 35
» Latest member: coronaman
» Forum threads: 160
» Forum posts: 1,296

Full Statistics

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

Latest Threads
spoop hunt (enginea)
Forum: NaaLaa 7 Code
Last Post: johnno56
01-18-2025, 08:23 PM
» Replies: 3
» Views: 67
Thunderbird Methuselah (G...
Forum: NaaLaa 7 Code
Last Post: johnno56
01-17-2025, 10:04 PM
» Replies: 2
» Views: 55
Irregular Beauty
Forum: NaaLaa 7 Code
Last Post: Marcus
01-09-2025, 07:38 PM
» Replies: 2
» Views: 188
Burning polygon mess
Forum: NaaLaa 7 Code
Last Post: johnno56
01-06-2025, 11:16 AM
» Replies: 3
» Views: 208
Things falling down
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
01-06-2025, 01:51 AM
» Replies: 4
» Views: 271
Fireworks
Forum: NaaLaa 7 Code
Last Post: johnno56
01-02-2025, 03:29 PM
» Replies: 3
» Views: 282
Happy New Year 2025
Forum: Everything else
Last Post: Marcus
01-02-2025, 07:18 AM
» Replies: 3
» Views: 295
GOLDEN WAVES (repost and ...
Forum: NaaLaa 7 Code
Last Post: Marcus
01-01-2025, 10:13 AM
» Replies: 9
» Views: 774
Start of a Christmas plat...
Forum: NaaLaa 7 Code
Last Post: johnno56
12-29-2024, 03:00 AM
» Replies: 2
» Views: 270
Merry Christmas
Forum: Everything else
Last Post: aliensoldier
12-27-2024, 07:29 PM
» Replies: 4
» Views: 409

 
  spoop hunt (enginea)
Posted by: Marcus - 01-18-2025, 09:09 AM - Forum: NaaLaa 7 Code - Replies (3)

Nothing finished here. This was one of my "test programs" when writing the enginea library and editor, so it's just a couple of enemies in some few rooms. The graphics and the music are ai generated, love the tune Smile  Some of the code might be of interest to others, so I'm posting it.

It's this thing: 



Attached Files
.zip   spoop_hunt.zip (Size: 3.08 MB / Downloads: 6)
Print this item

  Thunderbird Methuselah (Game of Life)
Posted by: 1micha.elok - 01-17-2025, 11:22 AM - Forum: NaaLaa 7 Code - Replies (2)

             
click each image to zoom in

CONWAY'S GAME OF LIFE
 Just a quick conversion to N7 

 Reference :
 "Thunderbird" methuselah evolution in the Game of Life
 https://rosettacode.org/wiki/Conway%27s_...e#BASIC256


Code:
'==============================================================
' CONWAY'S GAME OF LIFE
' Just a quick conversion to N7 
'
' Reference :
' "Thunderbird" methuselah evolution in the Game of Life
' https://rosettacode.org/wiki/Conway%27s_Game_of_Life#BASIC256
'==============================================================

'set window
#win32
set window "Game of Life",236,140,true
set redraw off

'color definition
black   = [0,0,0]
white   = [255,255,255]
purple  = [128,0,128]
green   = [0,255,0]
red     = [255,0,0]
yellow  = [255,255,0]

X = 59 ; Y = 35 ; H = 4

c = dim(X,Y)
cn = dim(X,Y)
cl = dim(X,Y)

'Thunderbird methuselah pattern
c[X/2-1][Y/3+1] = 1
c[X/2][Y/3+1]   = 1 
c[X/2+1][Y/3+1] = 1   
c[X/2][Y/3+3]   = 1
c[X/2][Y/3+4]   = 1
c[X/2][Y/3+5]   = 1

'initial value
s = 0
start = 1

'main loop
do
    'clear screen
    set color black
    cls
   
    alive = 0 
    stable = 1
    s = s + 1
   
    for y = 0 to Y-1
        for x = 0 to X-1
            xm1 = (x-1+X)%X
            xp1 = (x+1+X)%X
            ym1 = (y-1+Y)%Y
            yp1 = (y+1+Y)%Y
            cn[x][y] = c[xm1][y] + c[xp1][y]
            cn[x][y] = c[xm1][ym1] + c[x][ym1] + c[xp1][ym1] + cn[x][y]
            cn[x][y] = c[xm1][yp1] + c[x][yp1] + c[xp1][yp1] + cn[x][y]
           
            if c[x][y] = 1 then
                if cn[x][y] < 2 or cn[x][y] > 3 then
                    cn[x][y] = 0
                else
                    cn[x][y] = 1
                    alive = alive + 1
                endif
            else
                if cn[x][y] = 3 then
                    cn[x][y] = 1
                    alive = alive + 1
                else
                    cn[x][y] = 0
                endif
            endif
           
            if c[x][y] then
                if cn[x][y] then
                    if cl[x][y] then
                        set color purple        # adult
                    endif
                    if not cl[x][y] then
                        set color green         # newborn
                    endif
                else
                    if cl[x][y] then
                        set color red           # old
                    endif
                    if not cl[x][y] then
                        set color yellow        # shortlived
                    endif
                endif
               
                draw rect x*H,y*H,H,H,true
               
            endif
           
        next
    next
   
    redraw
    fwait 10
   
    # Copy arrays
    for i = 0 to X-1
        for j = 0 to Y-1
            if cl[i][j]<>cn[i][j] then stable = 0
            cl[i][j] = c[i][j]
            c[i][j] = cn[i][j]
        next
    next   
   
    if start then
        set color white
        set caret width()/2, height()-15
        center "Press Enter to Continue"
        redraw
        do;wait 1;until keydown(KEY_RETURN,true)
        start = false
    endif   
   
until not alive or stable

'final message
set color white
set caret width()/2,height()-15
if not alive then
    center "Died in "+s+" iterations"
else
    center "Stabilized in "+(s-2)+" iterations"   
endif
redraw

'Escape to quit
do;wait 1;until keydown(KEY_ESCAPE,true)

Print this item

  Irregular Beauty
Posted by: 1micha.elok - 01-07-2025, 12:46 AM - Forum: NaaLaa 7 Code - Replies (2)

IRREGULAR BEAUTY 3D


 Beyond isometric, the world unfolds,
 In 3D grace, its secrets told.
 Irregular forms, yet beauty reigns,
 Elegance shines where chaos remains.

   
click the image to zoom-in

Code:
'==================================================
' IRREGULAR BEAUTY 3D
' Beyond isometric, the world unfolds,
' In 3D grace, its secrets told.
' Irregular forms, yet beauty reigns,
' Elegance shines where chaos remains.
'
' References :
' - Pillars s3d (Marcus)
'==================================================

#win32

'library
include "s3d.n7"

'window size
set window "Irregular Beauty 3D", 480*screenw()/screenh(), 480, false
set redraw off

'color definition
black = [0,0,0]
white = [255,255,255]

'set up 3D view
S3D_SetView(primary, rad(90), 0.1, 360)
S3D_SetPerspectiveCorrection(S3D_NORMAL)

'cube 3D
cube = S3D_BeginMesh()
    S3D_Translate(0, -1, 0)
    S3D_Begin(S3D_QUADS)
   
        S3D_Color(0,0,0) 'bottom
        S3D_Vertex(1, 1, -1, 0, 0)
        S3D_Vertex(1, 1, 1, 0, 0)
        S3D_Vertex(-1, 1, 1, 0, 0)
        S3D_Vertex(-1, 1, -1, 0, 0)
       
        S3D_Color(200, 200, 0) 'top color
        S3D_Vertex(1, -1, 1, 0, 0)
        S3D_Vertex(1, -1, -1, 0, 0)   
        S3D_Vertex(-1, -1, -1, 0, 0)
        S3D_Vertex(-1, -1, 1, 0, 0)
       
        S3D_Color(200, 200, 0) 'back
        S3D_Vertex(1, 1, 1, 0, 0)
        S3D_Vertex(1, -1, 1, 0, 0)
        S3D_Vertex(-1, -1, 1, 0, 0)
        S3D_Vertex(-1, 1, 1, 0, 0)
       
        S3D_Color(150, 150, 0) 'front color
        S3D_Vertex(1, -1, -1, 0, 0)
        S3D_Vertex(1, 1, -1, 0, 0)
        S3D_Vertex(-1, 1, -1, 0, 0)
        S3D_Vertex(-1, -1, -1, 0, 0)
       
        S3D_Color(60, 60, 0) 'left color
        S3D_Vertex(-1, 1, 1, 0, 0)
        S3D_Vertex(-1, -1, 1, 0, 0)
        S3D_Vertex(-1, -1, -1, 0, 0)
        S3D_Vertex(-1, 1, -1, 0, 0)
       
        S3D_Color(60, 60, 0) 'right color
        S3D_Vertex(1, 1, -1, 0, 0)
        S3D_Vertex(1, -1, -1, 0, 0)
        S3D_Vertex(1, -1, 1, 0, 0)
        S3D_Vertex(1, 1, 1, 0, 0)
       
    S3D_End()           
S3D_EndMesh()


'-----------
' MAIN LOOP
'-----------
while not keydown(KEY_ESCAPE, true)
    angleA = (angleA + 90*0.01)%360
    S3D_Clear()
     
    'clear screen
    set color black;cls
    set color white

    'rotate
    S3D_RotateX(rad(90))
    S3D_RotateY(rad(135))
           
    'the whole pillars translation
    S3D_Translate(-43,83,-45)   
   
    for z = 0 to 30 - 1
        for x = 0 to 30 - 1         
           
            'pattern
            d = ((15-x) ^ 2 + (15-z) ^ 2) ^ 0.5
            s = 1.5*sin(d*2+rad(angleA))+2

            S3D_Push()
            S3D_Translate(x*3, 0, z*3)
            S3D_Scale(1.2, s, 1.2)
            S3D_Mesh(cube,0)
            S3D_Pop()                                        
                                                                                                                                                                 
        next
    next
           
    S3D_Render()

    redraw
    fwait 60
wend

Print this item

  Burning polygon mess
Posted by: Marcus - 01-06-2025, 08:41 AM - Forum: NaaLaa 7 Code - Replies (3)

Code:
visible vPolyT = dim(64)

set window "Burning polygon mess", screenw()/screenh()*512, 512, true
set redraw off
set color 0, 8, 32
cls

particles = []
while not keydown(KEY_ESCAPE)
    i = 0
    while i < sizeof(particles)
        if particles[i].Update()  i = i + 1
        else  free key particles, i
    wend
    particles[sizeof(particles)] = FireParticle(width(primary)/2, height(primary) - 64)
    set color 0, 8, 32, 96
    cls
    set additive true
    foreach p in particles p.Draw()
    set additive false
    redraw
    fwait 60
wend

function FireParticle(x, y)
    p = []
    p.pts = []
    for i = 1 to 3 + rnd(4)
        p.pts[sizeof(p.pts)] = (rnd() - 0.5)*48
        p.pts[sizeof(p.pts)] = (rnd() - 0.5)*48
    next
    p.x = x + rnd(32) - 16; p.y = y + rnd(32) - 16
    p.a = rnd(2*PI); p.as = (rnd() - 0.5)*0.2
    p.dx = (rnd() - 0.5)*2; p.dy = (rnd() - 0.75)*2
    p.r = 96; p.g = 80; p.b = 64
    p.fi = 0; p.p = 0
    p.Update = function()
        .x = .x + .dx; .y = .y + .dy
        .r = 8 + (.r - 8)*0.98; .g = 8 + (.g - 8)*0.96; .b = 8 + (.b - 8)*0.9
        .dx = .dx*0.975; .dy = max(.dy - 0.01, - 4)
        .a = .a + .as
        .fi = min(.fi + 0.05, 1); .p = .p + 0.003
        if .p >= 1 return false
        return true
    endfunc
    p.Draw = function()
        set color .r, .g, .b, .fi*(1 - .p)*255
        DrawPolyXForm(.pts, .x, .y, (1 - .p)*2, 2, .a, false)
    endfunc
    return p
endfunc

' n7 needs something like this in its core: 'draw poly xform', 'draw poly image xform'
function DrawPolyXForm(points, x, y, sx, sy, a, scaleFirst)
    if scaleFirst
        for i = 0 to sizeof(points)/2 - 1
            px = points[i*2]*sx; py = points[i*2 + 1]*sy
            vPolyT[i*2] = x + px*cos(a) - py*sin(a)
            vPolyT[i*2 + 1] = y + py*cos(a) + px*sin(a)
        next
    else
        for i = 0 to sizeof(points)/2 - 1
            px = points[i*2]; py = points[i*2 + 1]
            vPolyT[i*2] = x + (px*cos(a) - py*sin(a))*sx
            vPolyT[i*2 + 1] = y + (py*cos(a) + px*sin(a))*sy
        next
    endif
    draw poly vPolyT, true, sizeof(points)/2
endfunc

Print this item

  Things falling down
Posted by: Marcus - 01-04-2025, 09:51 AM - Forum: NaaLaa 7 Code - Replies (4)

I don't know, things falling down.

Code:
set window "Falling things", 480*screenw()/screenh(), 480, true
set redraw off
thing = createimage(63, 63)
set image thing
set color 0, 0, 0
cls
set color 255, 255, 255
draw ellipse 31, 31, 20, 20, true
set image primary
BoxBlur(thing, 8, 8)
set image thing
for y = 0 to height(thing) - 1  for x = 0 to width(thing) - 1
    set color 255, 255, 255, pixel(x, y)[0]
    set pixel x, y
next
set image primary
particles = []
for i = 1 to 256  particles[sizeof(particles)] = Particle(thing)
set color 32, 32, 96
cls
blura = rnd(2*PI)
while not keydown(KEY_ESCAPE)
    blura = blura + 0.01
    foreach p in particles  p.Update()
    set color 32, 32, 96, 64 + sin(blura)*32
    cls
    set additive true
    foreach p in particles  p.Draw()
    set additive false
    redraw
    fwait 60
wend

function Particle(img)
    return [
        img: img,
        x: rnd(width(primary)), y: rnd(height(primary)),
        alpha: 16 + rnd(16),
        scale: 0.25 + rnd()*1.75,
        spd: 0.25 + rnd()*2.75,
        rota: rnd(PI*2), rotspd: rnd()*0.1 - 0.05,
        offsa: rnd(PI*2), offse: rnd(128), offsspd: rnd()*0.1 - 0.05,
        Update: function()
            .y = .y + .spd
            if .y > height(primary) + height(.img)*0.5 then .y = .y - height(primary) - height(.img)
            .rota = (.rota + .rotspd)%(2*PI)
            .offsa = (.offsa + .offsspd)%(2*PI)
        endfunc,
        Draw: function()
            set color 255, 255, 255, .alpha
            draw image xform .img, .x + sin(.offsa)*.offse, .y,
                    .scale*(0.6 + sin(.rota)*0.4), .scale, .offsa, 0.5*width(.img), 0.5*height(.img)
        endfunc
        ]
endfunc

' BoxBlur
' -------
function BoxBlur(img, rx, ry)
    rx = max(int(rx), 0); ry = max(int(ry), 0)
    set image img
    w = width(img); h = height(img)
    data = dim(w, h)

    ' Blur vertically
    for y = 0 to h - 1  for x = 0 to w - 1  data[x][y] = pixeli(img, x, y)
    count = ry*2 + 1
    for x = 0 to w - 1
        sr = 0; sg = 0; sb = 0; sa = 0
        for y = -ry to ry
            p = data[x][y%h];
            sr = sr + Red(p); sg = sg + Green(p); sb = sb + Blue(p); sa = sa + Alpha(p)
        next
        for y = 0 to h - 1
            set color sr/count, sg/count, sb/count, sa/count
            set pixel x, y
            p = data[x][(y - ry)%h]
            sr = sr - Red(p); sg = sg - Green(p); sb = sb - Blue(p); sa = sa - Alpha(p)
            p = data[x][(y + ry + 1)%h]
            sr = sr + Red(p); sg = sg + Green(p); sb = sb + Blue(p); sa = sa + Alpha(p)
        next
    next
    ' Blur horizontally.
    for y = 0 to h - 1  for x = 0 to w - 1  data[x][y] = pixeli(img, x, y)
    count = rx*2 + 1
    for y = 0 to h - 1
        sr = 0; sg = 0; sb = 0; sa = 0
        for x = -rx to rx
            p = data[x%w][y]
            sr = sr + Red(p); sg = sg + Green(p); sb = sb + Blue(p); sa = sa + Alpha(p)
        next
        for x = 0 to w - 1
            set color sr/count, sg/count, sb/count, sa/count
            set pixel x, y
            p = data[(x - rx)%w][y]
            sr = sr - Red(p); sg = sg - Green(p); sb = sb - Blue(p); sa = sa - Alpha(p)
            p = data[(x + rx + 1)%w][y]
            sr = sr + Red(p); sg = sg + Green(p); sb = sb + Blue(p); sa = sa + Alpha(p)
        next
    next
    set image primary

    ' Pixeli helpers.
    function Alpha(c); return int(c/16777216); endfunc
    function Red(c); return int((c/65536))%256; endfunc
    function Green(c); return int((c/256))%256; endfunc
    function Blue(c); return c%256; endfunc
endfunc

Print this item

  Fireworks
Posted by: Marcus - 01-02-2025, 07:53 AM - Forum: NaaLaa 7 Code - Replies (3)

Happy new year, a bit late!

Code:
#win32
set window "2025", 640, 480
set redraw off
particles = []; t = 60
while not keydown(KEY_ESCAPE, true)
    t = t - 1
    if t <= 0
        particles[sizeof(particles)] = Firework(true, particles,
                rnd(width(primary)), height(primary))
        t = 30 + rnd(4)*30
    endif
    i = 0
    while i < sizeof(particles)
        if particles[i].Update()  i = i + 1
        else  free key particles, i
    wend
    set color 0, 0, 0, 16; cls
    foreach p in particles  p.Draw()
    redraw
    fwait 60
wend

function Firework(goingUp, list, x, y)
    if goingUp  a = 225 + rnd(90)
    else  a = rnd(360)
    p = [
        goingUp: goingUp, list: list,
        x: x, y: y,
        dx: cos(rad(a)), dy: sin(rad(a)),
        r: 128 + rnd(128), g: 128 + rnd(128), b: 128 + rnd(128), a: 255, spd: 0.5 + rnd()*0.5,
        Update: function()
            if .goingUp
                .x = .x + .dx*0.5; .y = .y + .dy*4; .dy = .dy + 0.005
                if .dy >= 0.25
                    for i = 1 to 100
                        .list[sizeof(.list)] = Firework(false, .list, .x, .y)
                    next
                    return false
                else
                    return true
                endif
            else
                .x = .x + .dx*.spd; .y = .y + .dy*.spd; .dy = .dy + 0.005
                .a = .a - 1.5*.spd
                return .a > 0
            endif
        endfunc,
        Draw: function()
            set color .r, .g, .b, .a
            draw pixel .x, .y
        endfunc]
    return p
endfunc

Some sound effects would be nice ...

Print this item

  Happy New Year 2025
Posted by: johnno56 - 12-30-2024, 09:14 PM - Forum: Everything else - Replies (3)

Here, downunder, it's new year's eve... Wishing that you all have a wonderful and safe new year!!

J

Print this item

  Start of a Christmas platformer
Posted by: Marcus - 12-28-2024, 09:19 AM - Forum: NaaLaa 7 Code - Replies (2)

Here's the start of a Christmas platform game. I won't finish it, but maybe the source code could be of interest to someone!

All the graphics were generated using Microsoft's free ai image generator thing (its output is in the works folder). It's such a nice thing to use instead of "programmer's art".

Video from other thread: https://naalaa.com/tmp/c2k24.mp4



Attached Files
.zip   c2k24.zip (Size: 8.56 MB / Downloads: 6)
Print this item

  Merry Christmas
Posted by: johnno56 - 12-24-2024, 10:59 AM - Forum: Everything else - Replies (4)

Well... For those of us in the land down under it's Christmas Eve...

Just want to wish everyone a very merry Christmas and an even better New Year!!

J Big Grin  Cool Rolleyes Confused  Big Grin

Print this item

  Sprite Editor
Posted by: johnno56 - 12-24-2024, 08:55 AM - Forum: NaaLaa 7 Questions - Replies (2)

I have a listing (N5 or N6 ?) for a sprite editor that I am trying to convert to N7.

There is a command that is used in converting the colour detected by the mouse into an RGB format... That command is 'SHR' (SHift register Right).

Reason: Using pixeli(x, y), to detect the colour, produces a number like:
black = 4278190080
white = 4294967295
red = 4294901760
green = 4278255360
blue = 4278190335

To convert to RGB three functions were used: n_c is the colour detected

rem    ---------------------------------------------------
rem        Convert to RGB format
rem    ---------------------------------------------------
function getB(n_c)
    return n_c AND 255
endfunc   

function getG(n_c)
    return (n_c SHR 8) AND 255
endfunc   

function getR(n_c)
    return (n_c SHR 16) AND 255
endfunc

I need to know if there is a method to replace SHR.

Print this item