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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 37
» Latest member: Ludwig
» Forum threads: 203
» Forum posts: 1,542

Full Statistics

Online Users
There are currently 144 online users.
» 1 Member(s) | 143 Guest(s)

Latest Threads
Raylib and SmallBASIC....
Forum: Programming
Last Post: aurel
6 minutes ago
» Replies: 1
» Views: 13
A diligent BASIC dialect(...
Forum: Programming
Last Post: luwal
9 hours ago
» Replies: 2
» Views: 58
RW3
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
Yesterday, 05:21 AM
» Replies: 6
» Views: 602
It's that time of year ag...
Forum: Everything else
Last Post: 1micha.elok
Yesterday, 05:09 AM
» Replies: 1
» Views: 45
Why all 80's Computers ha...
Forum: Everything else
Last Post: johnno56
05-03-2025, 02:08 PM
» Replies: 3
» Views: 103
The most used BASIC diale...
Forum: Programming
Last Post: johnno56
05-02-2025, 01:01 AM
» Replies: 13
» Views: 504
Most used game engines on...
Forum: Everything else
Last Post: johnno56
05-01-2025, 04:55 AM
» Replies: 1
» Views: 68
Suggestion: other classic...
Forum: Suggestions
Last Post: luwal
04-29-2025, 02:05 AM
» Replies: 2
» Views: 166
Suggestion: an example fo...
Forum: Suggestions
Last Post: luwal
04-27-2025, 06:16 PM
» Replies: 3
» Views: 182
BASIC replicator!
Forum: Everything else
Last Post: luwal
04-26-2025, 03:49 AM
» Replies: 2
» Views: 224

 
  How to make a race track ?
Posted by: 1micha.elok - 11-06-2024, 02:14 AM - Forum: NaaLaa 7 Questions - Replies (10)

Hi, Marcus,

   
I wonder how to make a race track (see the picture above), could you please advice me ?

This is the code that you made some months ago. 
I believe there are some minor changes with the latest s3d library 

I haven't use it (.... just kidding ...)  Big Grin

Code:
' A library that I'm working on, not finished at all, don't use it!
include "s3d.n7"

#dbg
set window "test", 320, 240, false, 2
set redraw off

roadImg = loadimage("road.png")
roadImgW = width(roadImg)
roadImgH = height(roadImg)
decorImg = loadimage("winter_tree.png")
tunnelImg = loadimage("tunnel_winter.png")
bgImg = loadimage("sky_winter.png")

' Set up 3d view.
S3D_SetView(primary, rad(90), 0.1, 20)
' Render polygons as we add them. If direct mode is false, all polygons are batched, sorted by
' distance and rendered when we call S3D_Render. Here we draw from back to front manually.
S3D_SetDirectMode(true)

road = []
for z = 0 to 999  road[z] = [x: sin(z*0.05)*6, y: sin(z*0.1)*3]

playerz = 0.0
playerx = 0
playery = -1
projected = dim(4) ' Don't want to spawn too many tables in a game loop, reused for calculations.
lastTick = clock()
while not keydown(KEY_ESCAPE, true)
    t = clock()
    dt = (t - lastTick)/1000
    lastTick = t

    playerz = playerz + 4*dt

    ' calculate camera y
    if int(playerz) < sizeof(road) - 2
        k = playerz%1
        playery = (1 - k)*road[int(playerz)].y + k*road[int(playerz) + 1].y - 0.5
    else
        playery = road[sizeof(road) - 1].y - 0.5
    endif
    ' move left and right
    if keydown(KEY_LEFT)  playerx = playerx - 4*dt
    if keydown(KEY_RIGHT) playerx = playerx + 4*dt

    set color 255, 255, 255
    draw image bgImg, 0, -80 - playery*5
   
    S3D_Clear()
    S3D_Translate(-playerx, -playery, -playerz)
    S3D_Begin(S3D_QUADS)
    didFill = false

    strips = 0
    fills = 0

    for i = int(playerz) + 20 to int(playerz)
        if i < sizeof(road) - 2
            strips = strips + 1
            ' Do we need to fill with snow color to hide distant objects?
            S3D_Project(projected, 0, road[i + 1].y, i + 1)
            y0 = round(projected[1])
            S3D_Project(projected, 0, road[i].y, i)
            y1 = round(projected[1])
            if y1 > y0
                if not didFill
                    didFill = true
                    fills = fills + 1
                    set color 218, 218, 218
                    draw rect 0, y0, width(primary), height(primary) - y0, true
                    set color 255, 255, 255
                endif
            else
                didFill = false
            endif

            ' Draw road.
            x0 = road[i].x
            x1 = road[i + 1].x
            set color 255, 255, 255
            S3D_Texture(roadImg)
            S3D_Vertex(x0 - 2, road[i].y, i, 0, roadImgH)
            S3D_Vertex(x0 + 2, road[i].y, i, roadImgW, roadImgH)
            S3D_Vertex(x1 + 2, road[i + 1].y, i + 1, roadImgW, 0)
            S3D_Vertex(x1 - 2, road[i + 1].y, i + 1, 0, 0)
           
            ' Draw sprites.
            ' Fade in.
            z = (i + 1) - playerz
            if z > 15
                a = ((20 - z)/5)*255
                set color 255, 255, 255, a
            endif
            if i%20 = 0
                S3D_Texture(tunnelImg)
                S3D_Vertex(road[i].x - 5, road[i].y + 0.2, i, 0, height(tunnelImg))
                S3D_Vertex(road[i].x + 5, road[i].y + 0.2, i, width(tunnelImg), height(tunnelImg))
                S3D_Vertex(road[i].x + 5, road[i].y - 3.5, i, width(tunnelImg), 0)
                S3D_Vertex(road[i].x - 5, road[i].y - 3.5, i, 0, 0)               
            else
                if i%2 = 0
                    S3D_Texture(decorImg)
                    x = x0 - 2.5               
                    S3D_Vertex(x - 0.4, road[i].y, i, 0, height(decorImg))
                    S3D_Vertex(x + 0.4, road[i].y, i, width(decorImg), height(decorImg))
                    S3D_Vertex(x + 0.4, road[i].y - 1, i, width(decorImg), 0)
                    S3D_Vertex(x - 0.4, road[i].y - 1, i, 0, 0)
                else
                    S3D_Texture(decorImg)
                    x = x0 + 2.5               
                    S3D_Vertex(x - 0.4, road[i].y, i, 0, height(decorImg))
                    S3D_Vertex(x + 0.4, road[i].y, i, width(decorImg), height(decorImg))
                    S3D_Vertex(x + 0.4, road[i].y - 1, i, width(decorImg), 0)
                    S3D_Vertex(x - 0.4, road[i].y - 1, i, 0, 0)
                endif
            endif
        endif
    next
    S3D_End()
    'S3D_Render()
    set caret 0, 0
    wln round(1/dt)
    wln strips
    wln fills
    redraw
    wait 1
wend



Attached Files
.zip   racing_s3d.zip (Size: 303.55 KB / Downloads: 4)
Print this item

  Theme Editor
Posted by: johnno56 - 11-05-2024, 01:12 AM - Forum: Everything else - Replies (2)

I had a few spare moments and decided to have a look at N7 themes... as you know, I run N7 via Wine, on my Linux Mint machine. Although Wine does a fairly good job at running Windows applications, it is far from perfect.

As you can see, by the image provided, Linux Mint "estimates" the font if the correct font is not loaded... I figured that installing Microsoft's core fonts (sudo apt-get install msttcorefonts) would do the trick, but I already have the core fonts installed... The most logical question to ask is, "What fonts does NGUI Theme Editor expect to find on its host system"?

The program itself functions as it should without error... It's just me being a bit "picky" about the "appearance" of the GUI... lol

Thank you.

J

   

Update: Ran Theme Editor via Windows 7 (Virtual Machine) and all the text looks ok...

Print this item

  Scrolling Text
Posted by: johnno56 - 11-01-2024, 08:43 AM - Forum: Everything else - Replies (10)

Ok. Here is an "oldie" question.

If I were to create, not that I will mind you, an old text-based adventure game** using N7, is there a way to scroll the text up the screen when the game output goes beyond a "screen full"?

** Interactive Fiction... I think is the going genre for text adventures...

If this is too involved or difficult then it would be best to ignore the request... after letting me know of course... lol

Cheers

J

Print this item

  Naalaa origins
Posted by: johnno56 - 10-22-2024, 06:04 PM - Forum: Everything else - Replies (2)

Marcus,

Looking through my drives, for anything Naalaa, I came across a reference to N4... Then I got to thinking (stop laughing) as to when Naalaa was created?

When you get a spare moment, would it be possible, to briefly go through the history of Naalaa? If you can, could you also include authorized video interviews; media references and general folk-lore? A twenty minute video or a 235page PDF would be appreciated... Nah! Kidding! It does not have to be authorized... lol

Thanks.

J

Print this item

  Maze generation
Posted by: Marcus - 10-17-2024, 05:20 AM - Forum: NaaLaa 7 Code - Replies (17)

Here's some code to generate a maze (https://en.wikipedia.org/wiki/Maze_generation_algorithm):

Code:
set window "maze", 640, 480
set redraw off

randomize time()
maze = GenerateMaze(24, 24)

side = 16

set color 0, 0, 0
cls
for x = 0 to sizeof(maze) - 1
    for y = 0 to sizeof(maze[0]) - 1
        dx = x*side
        dy = y*side
        set color 255, 255, 255
        if not maze[x][y].l  draw line dx, dy, dx, dy + side - 1
        if not maze[x][y].r  draw line dx + side - 1, dy, dx + side - 1, dy + side - 1
        if not maze[x][y].u  draw line dx, dy, dx + side - 1, dy
        if not maze[x][y].d  draw line dx, dy + side - 1, dx + side - 1, dy + side - 1
    next
next

redraw
while not keydown(KEY_ESCAPE, true)  fwait 60

' GenerateMaze
' ------------
' Return an array of the size w*h, where every element has four fields, l, r, u and d, telling if
' there's a way left, right, up and down.
function GenerateMaze(w, h)
    maze = fill([vis: false, l: false, r: false, u: false, d: false], w, h)
    GenerateMazeRec(maze, rnd(sizeof(maze)), rnd(sizeof(maze[0])), 0)
    return maze
 
    function GenerateMazeRec(maze, x, y, dir)
        if x < 0 or x >= sizeof(maze) or y < 0 or y >= sizeof(maze[0])  return false
        if maze[x][y].vis  return false
        maze[x][y].vis = true
        if dir = 1
            maze[x][y].r = true
            maze[x + 1][y].l = true
        elseif dir = 2
            maze[x][y].l = true
            maze[x - 1][y].r = true
        elseif dir = 3
            maze[x][y].d = true
            maze[x][y + 1].u = true
        elseif dir = 4
            maze[x][y].u = true
            maze[x][y - 1].d = true
        endif
        visit = [1, 2, 3, 4]
        while sizeof(visit)
            index = rnd(sizeof(visit))
            if visit[index] = 1  GenerateMazeRec(maze, x - 1, y, 1)
            elseif visit[index] = 2  GenerateMazeRec(maze, x + 1, y, 2)
            elseif visit[index] = 3  GenerateMazeRec(maze, x, y - 1, 3)
            else  GenerateMazeRec(maze, x, y + 1, 4)
            free key visit, index
        wend
        return true
    endfunc
endfunc

I'll post some more code later, explaining how this can be used for creating a map for the wolf3d library.

Print this item

  slow down time
Posted by: aliensoldier - 09-28-2024, 01:45 PM - Forum: NaaLaa 7 Questions - Replies (5)

https://youtu.be/_MR_6p1_qzU

In this game there are moments where the action slows down, especially enemy shots and especially the shots of the final boss of each phase.

Thanks to this you can dodge enemy shots more easily, how could you program the game to slow down at specific moments?

Print this item

  Curious
Posted by: johnno56 - 09-08-2024, 05:38 AM - Forum: Everything else - Replies (12)

It has been very quiet of late. Just curious to know if everyone is still ok?

J

Print this item

  Convert String to Number
Posted by: 1micha.elok - 08-20-2024, 04:02 AM - Forum: NaaLaa 7 Questions - Replies (3)

Hi Marcus,

I'm making a tiny karaoke machine, but I can't find a function to convert string to number and to syncronize song and lyrics.
Could you please advise me ?

Code:
    'TOBE...synchronize lyrics and timestamps
    clearscreen()
    set caret 10,10
    for i = 1 to j-2      
       
        'time1 = left(lyrics[i],2) 'take the first two digits number of lyrics[i]
        'convert time1 from string to number
        'if 'real time' = time1 then display lyrics
                                       
        wln mid(lyrics[i],3,80)
        wait 3000 'this line should be removed if lyrics and timestamps are synchronized
    next

Herewith the full code 
Code:
'==================================================================================
'                               T.I.N.Y  K.A.R.A.O.K.E
'
' Songs :
' 1. Nathan Evans - Wellerman (Sea Shanty)
'    https://www.youtube.com/watch?v=bNQSMTNSnUw
'
' DISCLAIMER
'    It is not intended for commercial use and not for sale                      
'    No person or entity associated with this game received payment   
'    or anything of value, or entered into any agreement,             
'    in connection with any game assets used in this game.
'
'    All trademarks and game assets are the property of their respective owners. 
'    While every effort is made to acknowledge their works,
'    some of the game assets used in in this tiny game may not have
'    clear name of the artist/author/creator/developer to be referred with.
'    It may not include all relevant facts or the most up-to-date information.
'
'==================================================================================


'-----------------
' INITIALIZATION
'-----------------
set window "Karaoke",500,225,false,2

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

' table to store lyrics line by line
lyrics = []


'-----------
' MAIN LOOP
'-----------
do
    clearscreen()

    'karaoke menu
    set caret 10,10
    wln "Karaoke"
    wln "* Choose music file (wav)"
    wln "* Choose lyric file (txt)"
    wln
    wln "Press SPACE to continue or ESC to quit"
    do
        if keydown(KEY_ESCAPE,true) then end
        wait 1
    until keydown(KEY_SPACE,true)
   
    'loop until filename is not blank
    do
        filemusic  = openfiledialog("wav")
        filelyrics = openfiledialog("txt")
    until not filemusic="" and not filelyrics=""

    'loop until ready
    loopready("Are you ready",14)

    'read lyrics from text file line by line
    f = openfile(filelyrics)
    j = 1
    do
        lyrics[j] = frln(f)
        j = j + 1
    until frln(f) = unset
    free file f

    'load and play music
    load music 1,filemusic
    play music 1

    'TOBE...synchronize lyrics and timestamps
    clearscreen()
    set caret 10,10
    for i = 1 to j-2      
       
        'time1 = left(lyrics[i],2) 'take the first two digits number of lyrics[i]
        'convert time1 from string to number
        'if 'real time' = time1 then display lyrics
                                       
        wln mid(lyrics[i],3,80)
        wait 3000 'this line should be removed if lyrics and timestamps are synchronized
    next

    'loop until ready
    loopready("Next Song ",14)
    free music 1
loop


'-----------
' FUNCTIONS
'-----------
function clearscreen()
    set color black;cls;set color white
endfunc

function loopready(message,lineNum)
    do
        'clear inside a defined rectangle
        set color black
        draw rect 10,lineNum*15,300,15,1
   
        'continue ?
        set color white
        set caret 10,lineNum*15
        write message+" (Y/N) ?"
        answer = rln()
        if upper(answer)="N" then end
    until upper(answer)="Y"
endfunc



Attached Files
.zip   Karaoke.zip (Size: 188.81 KB / Downloads: 4)
Print this item

  LowResJam
Posted by: Marcus - 07-31-2024, 08:58 PM - Forum: Programming - Replies (6)

Here's a game jam that seems kind of fun: https://itch.io/jam/lowrezjam-2024 . It starts tomorrow.

Print this item

  Neon Breath
Posted by: Marcus - 07-30-2024, 10:28 AM - Forum: NaaLaa 7 Code - Replies (11)

This is my submission for the Jam for All BASIC Dialects (#6) (https://itch.io/jam/jam-for-all-basic-dialects-6). There are only two levels, are they easy or hard? I just can't tell.

Edit It requires the latest version of n7 (released today) if you want to re-compile it.



Attached Files
.zip   neon_breath.zip (Size: 9.78 MB / Downloads: 16)
Print this item