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: 137
» Forum posts: 1,164

Full Statistics

Online Users
There are currently 68 online users.
» 1 Member(s) | 66 Guest(s)
Bing, johnno56

Latest Threads
Manual
Forum: Everything else
Last Post: johnno56
7 minutes ago
» Replies: 2
» Views: 39
Xmas New Year
Forum: Suggestions
Last Post: Marcus
11-22-2024, 03:36 PM
» Replies: 17
» Views: 3,060
Santa by Marcus
Forum: NaaLaa 6 Code
Last Post: johnno56
11-18-2024, 05:41 PM
» Replies: 7
» Views: 158
How to code efficiently
Forum: NaaLaa 7 Questions
Last Post: 1micha.elok
11-17-2024, 09:31 AM
» Replies: 4
» Views: 174
How to make a race track ...
Forum: NaaLaa 7 Questions
Last Post: kevin
11-10-2024, 04:02 PM
» Replies: 8
» Views: 438
Start of a silly Galaga s...
Forum: NaaLaa 7 Code
Last Post: johnno56
11-08-2024, 08:22 AM
» Replies: 3
» Views: 207
Theme Editor
Forum: Everything else
Last Post: johnno56
11-05-2024, 06:45 PM
» Replies: 2
» Views: 162
Scrolling Text
Forum: Everything else
Last Post: kevin
11-04-2024, 02:17 PM
» Replies: 10
» Views: 492
Naalaa origins
Forum: Everything else
Last Post: johnno56
10-25-2024, 07:21 AM
» Replies: 2
» Views: 301
Maze generation
Forum: NaaLaa 7 Code
Last Post: johnno56
10-23-2024, 09:05 AM
» Replies: 17
» Views: 1,708

 
  Extended Simple3D version
Posted by: Marcus - 03-08-2024, 02:38 PM - Forum: NaaLaa 6 Questions - Replies (2)

Some years ago, on the old forum that went kabooom, I posted an extended version of the n6 Simple3D library. The posted version let you create and display some primitive 3d shapes (spheres, cubes, cylinders etc) and even load models in the off file format.
   Does anyone have a copy of the library I posted? Lots of code there that I don't want to rewrite for my new experiments ...

Print this item

  Off the air...
Posted by: johnno56 - 03-08-2024, 08:46 AM - Forum: Everything else - Replies (5)

I will be "off the air" from Saturday morning until Monday afternoon. Off on our annual camping break... yah... (not a fan of camping lol) Forecast temperatures for Saturday 39C, Sunday and Monday 38C... The "big three" camping issues... Flies; mosquitoes and Sunburn... I suppose it would be worse if it was hot...

Have a great weekend guys!

J

Print this item

  draw image xform, asteroids example
Posted by: Marcus - 03-07-2024, 05:32 PM - Forum: NaaLaa 7 Code - Replies (6)

This is not a full game, just a player that you can control and some asteroids that fly around. But there are lots of transformed image drawing going on, including the spinning and zooming background image. I'm curious about the fps on your machines? I have a solid 250fps here, but maybe this craptop is a laptop after all.



Attached Files
.zip   asteroids_example.zip (Size: 138.54 KB / Downloads: 10)
Print this item

  Textured polygons helper functions
Posted by: Marcus - 03-06-2024, 03:58 PM - Forum: NaaLaa 7 Code - Replies (1)

'draw poly image' can be hard to use and make sense of, so here is an example program with some helper functions.



Attached Files
.zip   poly_helper.zip (Size: 6.59 KB / Downloads: 7)
Print this item

  N7 logo on email
Posted by: 1micha.elok - 03-06-2024, 01:15 AM - Forum: Suggestions - Replies (1)

Hi, Marcus

I am a fan of Naalaa, you know it  Big Grin
I subcribe and receive email notification of new replies from the Naalaa's forum.
I notice that it is still N6 logo
   
click the image to zoom in

Perhaps ... it is time to change to new N7 logo ...  Cool

.png   logo_N7.png (Size: 8.96 KB / Downloads: 24)
click the image to zoom in

Print this item

  N7 version 24.03.05 released
Posted by: Marcus - 03-05-2024, 07:15 PM - Forum: Announcements - Replies (7)

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

I haven't experimented with (or even tested, to be honest) the new commands much yet, and the included examples are minimal. But I will provide game examples soon.

Release notes
2024-03-05

  • 'this.' can now be written as just '.'
  • Added the commands 'draw image xform' and 'draw poly image'. You can find two small examples under examples/help: draw_image_xform.n7 and draw_poly_image.n7

'draw image xform' is for drawing transformed (scaled and rotated) images. 'draw poly image' is for drawing texture mapped polygons.

Print this item

  Physics
Posted by: johnno56 - 03-04-2024, 05:50 AM - Forum: NaaLaa 7 Questions - Replies (10)

I cannot recall if I have raised this question before... forgive if I have... What is involved in creating a simple physics engine / library? Say something like Box2D or Box2D-lite? The big question(s)... Can N7 do it... and how?

J

Print this item

  Rotated and scaled image drawing
Posted by: Marcus - 03-03-2024, 10:49 AM - Forum: NaaLaa 7 Code - Replies (27)

I wrote a quick prototype of drawing images with arbitrary rotation and scaling in n7. The code may look a bit too complicated for just drawing a transformed image. But when I add this stuff to the core (implement it in C and add new commands to n7), I will also let you draw textured polygons with any number of points. Here I just draw a textured rectangle, four points.

It's slow, but it's gonna get a lot faster, of course.

I'm already thinking about adding support for z coordinates and perspective correct interpolation (for polygons). Would be fun to allow some 3d rendering as in naalaa 5.

Code:
include "list.n7"

'#win32
#dbg

visible vPoints = fill([x: 0, y: 0, u: 0, v: 0], 4)
visible vXval = List()
vXval.Add([0, 0, 0])
vXval.Add([0, 0, 0])

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

img = loadimage("logo.png")
pln width(img) + ", " + height(img)

a = 0
while not keydown(KEY_ESCAPE, true)
    a = (a + 1)%360
    set color 0, 0, 0
    cls
    set color 255, 255, 255, 0
    ' DrawImageTransformed(image, x, y, scale_x, scaleY, angle, pivot_x, pivot_y)
    ' draw scaled and centered (= pivot at center of image).
    DrawImageTransformed(img, 120, 240, 2, 2, 0, width(img)/2, height(img)/2)
    ' draw rotated and centered
    DrawImageTransformed(img, 320, 240, 1, 1, rad(a), width(img)/2, height(img)/2)
    ' draw rotated and scaled but put pivot at top left corner of image.
    DrawImageTransformed(img, 520, 240, 4, 4, rad(a), 0, 0)
    redraw
    fwait 60   
wend

function DrawImageTransformed(img, drawX, drawY, scaleX, scaleY, angle, pivotX, pivotY)
    srcX = 0
    srcY = 0
    srcW = width(img)
    srcH = height(img)
   
    xLeft = -pivotX*scaleX
    xRight = (srcW - pivotX)*scaleX
    yTop = -pivotY*scaleY
    yBottom = (srcH - pivotY)*scaleY
   
    vPoints[0].x = xLeft; vPoints[0].y = yTop; vPoints[0].u = 0; vPoints[0].v = 0
    vPoints[1].x = xRight; vPoints[1].y = yTop; vPoints[1].u = 1; vPoints[1].v = 0
    vPoints[2].x = xRight; vPoints[2].y = yBottom; vPoints[2].u = 1; vPoints[2].v = 1
    vPoints[3].x = xLeft; vPoints[3].y = yBottom; vPoints[3].u = 0; vPoints[3].v = 1
    for i = 0 to sizeof(vPoints) - 1
        x = vPoints[i].x*cos(angle) - vPoints[i].y*sin(angle)
        y = vPoints[i].y*cos(angle) + vPoints[i].x*sin(angle)
        vPoints[i].x = round(drawX + x)
        vPoints[i].y = round(drawY + y)
        if i = 0
            minX = vPoints[i].x
            maxX = vPoints[i].x
            minY = vPoints[i].y
            maxY = vPoints[i].y
        else
            minX = min(vPoints[i].x, minX)
            maxX = max(vPoints[i].x, maxX)
            minY = min(vPoints[i].y, minY)
            maxY = max(vPoints[i].y, maxY)
        endif
    next   
    if maxX < 0 or minX >= width(primary) or maxY < 0 or minY >= height(primary)  return
    set color 255, 255, 255, 0
    for y = minY to maxY
        numx = 0
        for i = 0 to sizeof(vPoints) - 1
            p0 = vPoints[i]
            p1 = vPoints[(i + 1)%sizeof(vPoints)]
            if p0.y <= y and p1.y > y or
                    p0.y > y and p1.y <= y
                dy = p1.y - p0.y
                if dy = 0
                    vXval[numx][0] = p0.x; vXval[numx][1] = p0.u; vXval[numx][2] = p0.v
                    numx = numx + 1
                    vXval[numx][0] = p1.x; vXval[numx][1] = p1.u; vXval[numx][2] = p1.v
                    numx = numx + 1
                else
                    f = (y - p0.y)/(p1.y - p0.y)
                    vXval[numx][0] = p0.x + f*(p1.x - p0.x)
                    vXval[numx][1] = p0.u + f*(p1.u - p0.u)
                    vXval[numx][2] = p0.v + f*(p1.v - p0.v)
                    numx = numx + 1
                endif
            endif
        next
        if numx
            vXval.size = numx
            vXval.SortByField(0, vXval.ASCENDING)
            for i = 0 to vXval.size - 2 step 2
                draw hraster img, y, vXval[i][0], vXval[i + 1][0],
                        vXval[i][1], vXval[i][2], vXval[i + 1][1], vXval[i + 1][2]
            next
        endif
    next   
   
    draw poly vPoints, false
endfunc



Attached Files
.zip   image_transform.zip (Size: 637.72 KB / Downloads: 12)
Print this item

  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