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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 36
» Latest member: bul71
» Forum threads: 169
» Forum posts: 1,360

Full Statistics

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

Latest Threads
nPixel
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
8 hours ago
» Replies: 10
» Views: 776
The Shadow Master
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
Yesterday, 07:08 AM
» Replies: 4
» Views: 120
N7 version 25.02.16 relea...
Forum: Announcements
Last Post: 1micha.elok
Yesterday, 01:55 AM
» Replies: 2
» Views: 48
Suggestion: support dynam...
Forum: Suggestions
Last Post: Marcus
02-15-2025, 05:23 PM
» Replies: 8
» Views: 1,053
N7 version 25.02.15 relea...
Forum: Announcements
Last Post: 1micha.elok
02-15-2025, 10:54 AM
» Replies: 1
» Views: 50
Ask help to fix errors (g...
Forum: NaaLaa 7 Questions
Last Post: 1micha.elok
02-15-2025, 09:35 AM
» Replies: 7
» Views: 422
3D Breakout, just a quick...
Forum: NaaLaa 7 Code
Last Post: Marcus
02-02-2025, 07:42 AM
» Replies: 6
» Views: 483
Render on an image before...
Forum: NaaLaa 6 Questions
Last Post: Marcus
01-27-2025, 03:56 PM
» Replies: 4
» Views: 366
Repurposed Sprite Editor
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
01-27-2025, 11:58 AM
» Replies: 13
» Views: 1,067
Alien Breed 3D II: The Ki...
Forum: Everything else
Last Post: Marcus
01-26-2025, 07:58 AM
» Replies: 2
» Views: 310

 
  Some spinning balls
Posted by: Marcus - 03-02-2024, 07:24 PM - Forum: NaaLaa 7 Code - Replies (4)

Remember something very similar from n6, some balls spinning around in space.

Code:
' balls.n7
' --------

include "list.n7"

#win32

set window "Balls", 640, 480
set redraw off

balls = List()
for z = -2 to 2  for y = -2 to 2  for x = -2 to 2  balls.Add(Ball(x, y, z))

additiveMode = false
a1 = 0; a2 = 0; az = 0
while not keydown(KEY_ESCAPE, true)
    if keydown(KEY_SPACE, true)  additiveMode = not additiveMode
    a1 = (a1 + 0.02)%(PI*2)
    a2 = (a2 + 0.013)%(PI*2)
    az = (az + 0.009)%(PI*2)
    for i = 0 to balls.size - 1
        ball = balls[i]
        ball.px = ball.x; ball.py = ball.y; ball.pz = ball.z
        x = ball.px*cos(a1) - ball.py*sin(a1); y = ball.py*cos(a1) + ball.px*sin(a1)
        ball.px = x; ball.py = y
        z = ball.pz*cos(a2) - ball.py*sin(a2); y = ball.py*cos(a2) + ball.pz*sin(a2)
        ball.pz = z; ball.py = y
        ball.pz = ball.pz + 5.5 + sin(az)*0.5
        ball.px = 320 + 200*ball.px/ball.pz; ball.py = 240 + 200*ball.py/ball.pz
    next
    balls.SortByField("pz", balls.DESCENDING)
    set color 0, 0, 0, 64
    cls
    set additive additiveMode
    for i = 0 to balls.size - 1
        s = 100/balls[i].pz
        intens = 255 - (balls[i].pz - 1)*50
        set color intens/2, intens/2, intens/2
        draw ellipse balls[i].px, balls[i].py, s, s, true
        set color intens*0.75, intens*0.75, intens*0.75
        draw ellipse balls[i].px - s*0.4, balls[i].py - s*0.4, s*0.25, s*0.25, true
    next
    set additive false
    set color 255, 255, 255
    set caret width(primary)/2, 480 - fheight()*2
    center "Press spacebar to toggle additive drawing"
    
    redraw
    fwait 60
wend

function Ball(x, y, z)
    return [x: x, y: y, z: z, px: 0, py: 0, pz: 0]
endfunc

Print this item

  PolyLine library
Posted by: Marcus - 02-29-2024, 04:25 PM - Forum: NaaLaa 7 Code - Replies (20)

Here's a small library that could be used for enemy movement in space shootemups (that's the only use I can think of), example included.

The truth is that I had made quite a nice shootemup that used the library. But when I was going to zip it I wanted to delete all built files (exe, n7a, n7b ...). Instead of deleting the exe file, I deleted the source code Sad


Edit  I updated the zip with a new version of the library and some more examples of how it can be used in a shootemup.



Attached Files
.zip   polyline.zip (Size: 7.05 KB / Downloads: 9)
Print this item

  Sleepy tunnel
Posted by: Marcus - 02-29-2024, 03:44 PM - Forum: NaaLaa 7 Code - Replies (8)

A 3d tunnel effect.

Code:
' sleepy_tunnel.n7
' ----------------

#win32
constant WIN_W = 640, WIN_H = 480
set window "Sleepy Tunnel", WIN_W, WIN_H
set redraw off
aa = 0
while not keydown(KEY_ESCAPE, true)
    aa = aa + 0.05
    zoffset = (zoffset + 0.001)%0.01
    set color 0, 0, 0
    cls
    set color 255, 255, 255
    maxz = 0.1 + 150*0.01
    for i = 150 to 0
        z = 0.1 + i*0.01 - zoffset
        s = 50/z
        x = cos(z*5 + aa)*(z - 0.1)*50
        y = sin(z*5 + aa)*(z - 0.1)*25
        intens = 255 - 255*z*1.5/maxz
        set color intens*0.5, intens, intens*0.75
        draw pixel WIN_W/2 + x/z + cos(rad(0))*s, WIN_H/2 + y/z + sin(rad(0))*s
        a = 15
        while a <= 360
            draw line to WIN_W/2 + x/z + cos(rad(a))*s, WIN_H/2 + y/z + sin(rad(a))*s
            a = a + 15
        wend
    next
    redraw
    fwait 60
wend



Attached Files
.n7   sleepy_tunnel.n7 (Size: 868 bytes / Downloads: 3)
Print this item

  Simple Scaling and Rotating
Posted by: 1micha.elok - 02-28-2024, 11:57 AM - Forum: NaaLaa 7 Code - Replies (7)

Just a simple scaling and rotating  Cool

Possible use in games, such as
- Space Invaders, Gargoyle Attack
- Tetris

Code:
'==========================================
'       SIMPLE SCALING AND ROTATING
'
'Possible use in games, such as
'- Space Invaders, Gargoyle Attack
'- Tetris
'
'Limitation
'Rotate : only multiplication of 90 degree
'==========================================


'----------------
' INITIALIZATION
'----------------
set window "Pixel Art", 150, 150, false,4
set redraw off

'Color definition
visible cBlack  = [0,0,0]
visible cGreen  = [0,255,0]

'Sprite class definition
Sprite =
[
    '--- Properties ---
    data: [
    [0,0,0,0,0,0,0,0],
    [0,0,1,0,0,1,0,0],
    [0,1,1,1,1,1,1,0],
    [0,1,1,0,0,1,1,0],
    [0,0,1,1,1,1,0,0],
    [0,1,1,1,1,1,1,0],
    [0,1,0,0,0,0,1,0],
    [0,0,0,0,0,0,0,0]
    ],
   
    img: 0, x:0, y:0,    
   
    '--- Methods ---
    Transform_Scale : function(s)
                        this.img = Scale(this.data,s)
                        this.x   = (width(primary)-8*s)/2
                        this.y   = (height(primary)-8*s)/2
                       endfunc, 
    Transform_Rotate : function(s,r)
                        this.img = Rotate(this.data,s,r)
                        this.x   = (width(primary)-8*s)/2
                        this.y   = (height(primary)-8*s)/2
                       endfunc
]

'--------------
' MAIN PROGRAM
'--------------
TitleScreen()
scale   = 1
rotate  = 0
do
    'Prepare screen
    set color cBlack; cls
    set color cGreen

    'Draw Sprite
    'Sprite.Transform_Scale(scale)
    Sprite.Transform_Rotate(scale,rotate)
    draw image Sprite.img,Sprite.x,Sprite.y

    'Pause and wait until SPACE BAR is pressed, ESCAPE to quit
    set caret width(primary)/2, height(primary)-20
    center "SPACE BAR"; redraw
    do;wait 1;if keydown(KEY_ESCAPE,true) end;until keydown(KEY_SPACE,true)
    if scale < 10 then
        scale = scale + 1
    else
        scale = 1
    endif
    if rotate < 3 then
        rotate = rotate + 1
    else
        rotate = 0
    endif  

    free image Sprite.img 'free image from memory
loop

'-----------
' FUNCTIONS
'-----------
function Scale(data,s)
    img = createimage(8*s,8*s); set image img
    for y = 0 to 7
        for x = 0 to 7
            if data[y][x] then
                set color cGreen
            else 
                set color cBlack
            endif
            draw rect x*s,y*s,s,s,1
        next
    next
    set image primary; return img
endfunc

function Rotate(data,s,r)
    img = createimage(8*s,8*s); set image img
    for y = 0 to 6
        for x = 0 to 6
            if data[y][x] then
                set color cGreen
            else 
                set color cBlack
            endif
                       
            '(a,b)  = center point of rotation
            '(x,y)  is rotated into (m,n)
            'd      = angle of rotation in radian
            'm      = cos(d)*(x-a)-sin(d)*(y-b)+a
            'n      = sin(d)*(x-a)+cos(d)*(y-b)+b
            a = 3
            b = 3
            d = r*90*(22/7)/180
            m = (round((cos(d)*(x-a))-(sin(d)*(y-b))+a))
            n = (round((sin(d)*(x-a))+(cos(d)*(y-b))+b))
                     
            draw rect m*s,n*s,s,s,1
        next
    next
    set image primary; return img
endfunc

function TitleScreen()
    set caret width(primary)/2,5
    center "Scaling and"
    center "Rotating"
    set caret width(primary)/2, height(primary)-20
    center "Press ENTER"
    redraw
    do;wait 1;until keydown(KEY_RETURN,true)
endfunc

Print this item

  A game of pool...
Posted by: kevin - 02-22-2024, 02:16 PM - Forum: NaaLaa 7 Code - Replies (14)

Here's a pool game that I have been working on. You can play against another player, or the computer.

I've tried to include playing hints that show up as you play - there's no time pressure, so you can take the time to read these as they appear in the lower part of the screen.

The main control is the mouse or trackpad. When it is your turn to play, press AND HOLD DOWN the left mouse button to lift the pool cue. You can then position the cue by using the mouse, while keeping the mouse button pressed down. The further away from the white ball the mouse goes, the more powerful the shot will be. When you are happy with the mouse position, release the mouse button to take the shot.

There's no image files needed, so you can just run the n7 file from the zip, or use the executable.

   


.zip   pool.zip (Size: 842.52 KB / Downloads: 12)

Print this item

  Mouse
Posted by: johnno56 - 02-21-2024, 08:34 PM - Forum: NaaLaa 7 Questions - Replies (6)

Quick question...

Are there any commands to 'hide' the mouse and to 'read' the mouse wheel?

Just curious. If not, it might be a good idea to add them... purely selfish reasons... lol

J

Print this item

  SFX
Posted by: johnno56 - 02-19-2024, 07:02 PM - Forum: NaaLaa 7 Questions - Replies (8)

Marcus,

I am curious as to "how" your SFX program actually generates tones. For instance: Most Music Notation software relies on a "soundfont" (database of stored samples) to play various instruments but usually require the use of a midi compatible sound card...  Are you using a 'secret' method (similar to KFC's herbs and spices) to access the midi port?... Perhaps a little magic or 'slight of hand'? Just curious...

J

Print this item

  Space Side Scroller
Posted by: johnno56 - 02-19-2024, 10:50 AM - Forum: NaaLaa 7 Code - Replies (9)

This is a simple side scroller. Collect as many "stars" as you can. It stars off slow, but as your score increases, so does your speed. But, if you miss a star, you will lose a life....

Mouse controlled (vertical only) - Note: The sounds were created by Marcus's SFX library....

For those who are patient enough... post your final scores.... lol


.zip   scroller.zip (Size: 757.53 KB / Downloads: 6)

J

Print this item

  N7 version 24.02.16 released
Posted by: Marcus - 02-17-2024, 06:49 PM - Forum: Announcements - Replies (12)

Here comes a new release with the online high-score library (ohs), updated since I posted it in a thread a while ago, and the sfx library. 

2024-02-16

  • The compiler and the generated programs are from now and on 64 bit. libgcc_s_dw2-1.dll is no longer required for the programs to run. ibwinpthread-1.dll and libportaudio.dll are still required but have been replaced with 64 bit versions
  • Added the sfx library for creating sound effects with two examples in examples/sfx_library
  • Added the ohs library for online high-score lists with two examples in examples/ohs_library
  • Added some programs by members of the naalaa forum to examples/other
  • Fixed an issue with 'draw pixel'

https://naalaa.com/n7/N7_240216.zip

Print this item

  horizontal scroll bar
Posted by: aliensoldier - 02-17-2024, 04:05 PM - Forum: Suggestions - Replies (4)

I think a horizontal bar is necessary so that when the code is very wide it can be moved horizontally comfortably.

I mention this because when creating the scenarios in the platform game that I am making, the scenario is a list and I have not been able to make it very long because I had to move with the keyboard arrows from left to right and when I reached the end I returned to the beginning.

And it was very tiresome to have to move around with the keys again.

Print this item