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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 46
» Latest member: shahidkhandp
» Forum threads: 296
» Forum posts: 2,113

Full Statistics

Online Users
There are currently 76 online users.
» 0 Member(s) | 73 Guest(s)
Applebot, Bing, Google

Latest Threads
Carousel Menu kind of...
Forum: NaaLaa 7 Code
Last Post: johnno56
12-05-2025, 11:54 PM
» Replies: 11
» Views: 498
Sorry for being absent
Forum: Everything else
Last Post: 1micha.elok
11-27-2025, 03:24 AM
» Replies: 3
» Views: 606
RCBasic is the official B...
Forum: Programming
Last Post: luwal
11-23-2025, 03:33 PM
» Replies: 0
» Views: 731
Raylib again....
Forum: Suggestions
Last Post: luwal
11-21-2025, 08:06 AM
» Replies: 0
» Views: 904
The magic number is 6174
Forum: NaaLaa 7 Code
Last Post: kevin
11-19-2025, 09:09 AM
» Replies: 5
» Views: 1,477
Keys
Forum: NaaLaa 7 Questions
Last Post: johnno56
11-19-2025, 02:48 AM
» Replies: 2
» Views: 1,202
Not Frogger
Forum: NaaLaa 7 Code
Last Post: kevin
11-08-2025, 01:03 PM
» Replies: 6
» Views: 1,410
Gameboy platformer
Forum: NaaLaa 7 Code
Last Post: kevin
11-07-2025, 09:30 AM
» Replies: 13
» Views: 1,992
Scharf Brot Fractal
Forum: NaaLaa 7 Code
Last Post: kevin
11-04-2025, 06:54 PM
» Replies: 6
» Views: 2,503
1micha.elok, kevin, johnn...
Forum: Programming
Last Post: aurel
11-03-2025, 09:52 AM
» Replies: 14
» Views: 5,163

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

  GOLDEN WAVES (repost and modified)
Posted by: 1micha.elok - 12-22-2024, 12:59 PM - Forum: NaaLaa 7 Code - Replies (9)

 THE SIXTH FORM OF GOLDEN WAVES (repost and modified)

                   
click image to zoom in

 CONTROL KEYS :
 ESC        = quit
 UP, DOWN    = amplitudo value,0-100
 LEFT,RIGHT  = chaos value,0-2

 PRESET FORMS : (Press 1-5)
  1        = calm
  2        = ripple
  3        = shaked
  4        = disturbed
  5        = irregular

 LOGS :
 - Posted by johnno1956 on the naalaa forum. 
   "Here is a short graphical demo that started with Basic256, sdlBasic and RCBasiWhy not N7?"
 - Modified on Dec 2024 by Micha
   Add interactivity 


Code:
'=====================================================
' THE SIXTH FORM OF GOLDEN WAVES (repost and modified)
'
' CONTROL KEYS :
' ESC         = quit
' UP, DOWN    = amplitudo value,0-100
' LEFT,RIGHT  = chaos value,0-2
'
' PRESET FORMS :
'   1         = calm
'   2         = ripple
'   3         = shaked
'   4         = disturbed
'   5         = irregular
'
' LOGS :
' - Posted by johnno1956 on the naalaa forum.
'   "Here is a short graphical demo that
'    started with Basic256, sdlBasic and RCBasic
'    Why not N7?"
' - Modified on Dec 2024 by Micha
'   Add interactivity 
'=====================================================

'set window size
#win32
set window "The 6th Form of Golden Waves", 600, 470
set redraw off

'color definition
black       = [0,0,0]
leftgold    = [60, 60, 0]
rightgold   = [150,150,0]
white       = [255,255,255]

'initial value
amplitudo   = 0
chaos       = 0
name        = "calm"

'main loop
do
for t = 10 to 60 step 0.1
   
    'clear screen
    set color black; cls

    'infobox
    set color white
    set caret 10,10
    wln "Amplitudo = "+amplitudo
    wln "Chaos     = "+chaos
    wln "Name      = "+name
                       
    for y1 = 0 to 24
        for x1 = 0 to 24

            'coordinates
            x = (12 * (24 - x1)) + (12 * y1)
            y = (-6 * (24 - x1)) + (6 * y1) + 300
            d = ((10 - x1) ^ 2 + (10 - y1) ^ 2) ^ 0.5

            'controls       
            if keydown(KEY_UP,true) then
                amplitudo = min(amplitudo+1,100)
                name = "custom"
            elseif keydown(KEY_DOWN,true) then
                amplitudo = max(amplitudo-1,0)
                name = "custom"
            elseif keydown(KEY_RIGHT,true) then
                chaos = min(chaos+0.01,2)
                name = "custom"
            elseif keydown(KEY_LEFT,true) then
                chaos = max(chaos-0.01,0)
                name = "custom"
            endif
           
            if keydown(KEY_1,true) then
                amplitudo   = 0
                chaos       = 0
                name        = "calm"
            elseif keydown(KEY_2,true) then
                amplitudo   = 3
                chaos       = 1
                name        = "ripple"
            elseif keydown(KEY_3,true) then
                amplitudo   = 25
                chaos       = 0.1
                name        = "shaked"
            elseif keydown(KEY_4,true) then
                amplitudo   = 60
                chaos       = 0.3
                name        = "disturbed"
            elseif keydown(KEY_5,true) then
                amplitudo   = 100
                chaos       = 2
                name        = "irregular"
            endif
           
            'form/pattern 
            h = amplitudo*sin(d * chaos + t) + 70

            'on top
            set color [100 + h, 100 + h, h]
            gold = [x, y - h, x + 10, y + 5 -h, x + 20, y - h, x + 10, y - 5 - h]
            draw poly gold, 1
           
            'left side
            set color leftgold
            gold = [x, y - h, x + 10, y + 5 - h, x + 10, y, x, y - 5]
            draw poly gold, 1
           
            'right side
            set color rightgold
            gold = [x + 10, y + 5 - h, x + 10, y, x + 20, y - 5, x + 20, y - h]
            draw poly gold, 1
           
            'ESC to quit
            if keydown(KEY_ESCAPE) end
        next
    next
   
    redraw
    fwait 30
next

loop

Print this item

  Clock (repost and modified)
Posted by: 1micha.elok - 12-21-2024, 04:12 AM - Forum: NaaLaa 7 Code - Replies (4)

Clock (repost and modified)
Repost from an old archive N7 Marcus
Date : 10-15-2022


Code:
'====================================
'Clock (repost and modified)
'
'Repost from an old archive N7 Marcus
'Date : 10-15-2022
'
'Control key
'- ESC to quit
'====================================

'set window size
#win32
set window "Clock", 400, 400
set redraw off

'color definition
gray    = [200,200,200]
black   = [0,0,0]
white   = [255,255,255]
red     = [255,0,0]
yellow  = [255,255,0]
green   = [0,255,0]
orange  = [255,165,0]

'font
bigfont = createfont("arial", 48, true, false, false, true)

'main loop
do
    'background
    set color black;cls

    t = datetime()
   
    'clock center
    centerx = width()/2
    centery = height()/3+20

    'clock border
    set color white
    rx = width()/3
    ry = height()/3
    draw ellipse centerx, centery, rx, ry, true
       
    'clock body
    set color rnd(150,200),rnd(150,200),rnd(150,200) 'random color
    draw ellipse centerx, centery, rx - 4, ry - 4, true

    'clock marks
    set color yellow
    for i = 0 to 11
        draw ellipse centerx+(rx-15)*cos(30/180*PI*i),centery+(ry-15)*sin(30/180*PI*i),4,4,true
    next
    set color black
    i = t.hour-3
    draw ellipse centerx+(rx-15)*cos(30/180*PI*i),centery+(ry-15)*sin(30/180*PI*i),6,6,true

    'arrow second
    set color red
    a = rad(360*t.second/60 - 90)
    DrawThickLine(centerx, centery, centerx + cos(a)*(centerx*0.6 - 4), centery + sin(a)*(centery*0.6 - 4), 2)
  
    'arrow long hand
    set color black
    a = rad((t.minute/5*30) - 90)
    DrawArrow(centerx, centery, centerx + cos(a)*(centerx*0.6 - 4), centery + sin(a)*(centery*0.6 - 4), 6)
      
    'arrow short hand
    set color black
    a2 = rad(360*(t.hour%12)/12 - 90)+rad(((t.minute/5*30)+5 - 90)/12)
    DrawArrow(centerx, centery, centerx + cos(a2)*(centerx*0.3 - 4), centery + sin(a2)*(centery*0.3 - 4), 5)
  
    'clock center
    set color black
    draw ellipse centerx, centery, 8, 8, true
   
    'digital clock
    set color green
    set font bigfont
    set caret width()/2,height()-70
    if len(t.hour) = 1    then
        myhour = "0"+t.hour
    else
        myhour = t.hour
    endif
    if len(t.minute) = 1  then
        myminute = "0"+t.minute
    else
        myminute = t.minute
    endif
    if len(t.second) = 1  then
        mysecond = "0"+t.second
    else
        mysecond = t.second
    endif
    center myhour+":"+myminute+":"+mysecond
   
    if keydown(KEY_ESCAPE,true) then end
  
    redraw
    fwait 1
loop

'functions
function DrawThickLine(x1, y1, x2, y2, thickness)
    dx = x2 - x1
    dy = y2 - y1
    k = 0.5*thickness/sqr(dx*dx + dy*dy)
    ddx = -dy*k
    ddy = dx*k
    p = [
        round(x1 + ddx), round(y1 + ddy),
        round(x2 + ddx), round(y2 + ddy),
        round(x2 - ddx), round(y2 - ddy),
        round(x1 - ddx), round(y1 - ddy)]
    draw poly p, true
endfunc

function DrawArrow(x1, y1, x2, y2, thickness)
    dx = x2 - x1
    dy = y2 - y1
    k = 0.5*thickness/sqr(dx*dx + dy*dy)
    ddx = -dy*k
    ddy = dx*k
    p = [
        x1, y1,
        x1*0.25 + x2*0.75 - ddx, y1*0.25 + y2*0.75 - ddy,
        x2, y2,
        x1*0.25 + x2*0.75 + ddx, y1*0.25 + y2*0.75 + ddy]
      
    draw poly p, true
endfunc

Print this item

  Canabis Curve (repost)
Posted by: 1micha.elok - 12-20-2024, 02:48 PM - Forum: NaaLaa 7 Code - Replies (1)

Cannabis curve
 repost from old archive
 date:08-07-2022


Code:
' ------------------------------------------------
' Cannabis curve
' repost from old archive N7 Marcus
' date:08-07-2022
' see also
' https://www.facebook.com/groups/2057165187928233
'
' control key :
' ESC to quit
' ------------------------------------------------

'set window size
#win32
set window "Cannabis curve", 640, 480
set redraw off
randomize time()

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

'initial value
px = 0; py = 0
detail = 0.01

'Main loop
do

    set color black; cls 'clear screen

    set color rnd(100,255),rnd(50,255),rnd(50,255) 'random color of canabis curve

    for a = 0 to 2*PI step detail

        'calculate coordinate
        x = width()/2 + 100*(sin(a) + 1)*cos(a)*(9*cos(8*a)/10 + 1)*(cos(24*a)/10 + 1)*(cos(200*a)/10 + 9/10)
        y = 64+100*sin(a)*(sin(a) + 1)*(9*cos(8*a)/10 + 1)*(cos(24*a)/10 + 1)*(cos(200*a)/10 + 9/10)
   
        'each time, continue draw line from the last point
        if a > 0  then
            draw line px, py, x, y
            draw line px-5,py-5,x-5,y-5
            draw line px-10,py-10,x-10,y-10
            draw line px-15,py-15,x-15,y-15
        endif
        px = x; py = y  'swap value 
       
        'Escape to quit
        if keydown(KEY_ESCAPE,true) then end
   
        fwait 100
        redraw
    next

    fwait 100
loop

Print this item

  Mark Sibly, the creator of Blitz Basic has sadly passed away.
Posted by: luwal - 12-14-2024, 04:01 AM - Forum: Programming - Replies (3)

Mark Sibly, the creator of Blitz Basic (as well as one of the developers of games like Gloom, Skidmarks and Guardian) has sadly passed away.

https://www.syntaxbomb.com/general-discu...ssed-away/
https://eab.abime.net/showthread.php?t=119298

Print this item