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: 136
» Forum posts: 1,157

Full Statistics

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

Latest Threads
Xmas New Year
Forum: Suggestions
Last Post: 1micha.elok
3 hours ago
» Replies: 13
» Views: 2,940
Santa by Marcus
Forum: NaaLaa 6 Code
Last Post: johnno56
11-18-2024, 05:41 PM
» Replies: 7
» Views: 127
How to code efficiently
Forum: NaaLaa 7 Questions
Last Post: 1micha.elok
11-17-2024, 09:31 AM
» Replies: 4
» Views: 147
How to make a race track ...
Forum: NaaLaa 7 Questions
Last Post: kevin
11-10-2024, 04:02 PM
» Replies: 8
» Views: 373
Start of a silly Galaga s...
Forum: NaaLaa 7 Code
Last Post: johnno56
11-08-2024, 08:22 AM
» Replies: 3
» Views: 185
Theme Editor
Forum: Everything else
Last Post: johnno56
11-05-2024, 06:45 PM
» Replies: 2
» Views: 140
Scrolling Text
Forum: Everything else
Last Post: kevin
11-04-2024, 02:17 PM
» Replies: 10
» Views: 429
Naalaa origins
Forum: Everything else
Last Post: johnno56
10-25-2024, 07:21 AM
» Replies: 2
» Views: 264
Maze generation
Forum: NaaLaa 7 Code
Last Post: johnno56
10-23-2024, 09:05 AM
» Replies: 17
» Views: 1,504
Curious
Forum: Everything else
Last Post: Marcus
10-12-2024, 11:18 AM
» Replies: 12
» Views: 2,704

 
  N7 Lander 2
Posted by: johnno56 - 04-19-2024, 11:12 PM - Forum: NaaLaa 7 Code - Replies (3)

Do not ask about version one. Let's not go there... lol

Anyway... Here is version 2 using the new pixeli() command for collision detection.

You know how it works. Left and right arrow keys to move left and right. Up arrow to apply vertical thrust. Land on the green Pad. (Not too fast) Watch your fuel... there is no more until the very last level. Spoiler alert: Hold your breath for level nine.

ToDo:

Collision detection still flaky for level 10.
No background noise or music track.... open to suggestions.
Add "your" recommendations... (assuming "I" can do it. lol)


.zip   lander2.zip (Size: 952.26 KB / Downloads: 15)

Print this item

  HELP. The Mummy in s3d
Posted by: 1micha.elok - 04-18-2024, 12:52 PM - Forum: NaaLaa 7 Questions - Replies (3)

New S3d Library

           
click each image to zoom - in

The mummy is everywhere when I am facing North, South, West etc ... lol .....
Is there a way to put the mummy somewhere in certain coordinate (x,y,z) ?

Code:
'==================================================
' THE MAZE II
' Part 1. Sand Desert
' Part 2. to be
' Part 3. to be
'
' Control :
' SPACE     = move forward
' Mouse     = see around
'
' Reference :
' - s3d.n7 library, ex6_heightmap.n7 by Marcus
'
' Sand texture https://images.app.goo.gl/QwsHZq7hZVdyNXB76
' Mummy1 https://images.app.goo.gl/uiosCKdMHraZPfoC7
' Title https://images.app.goo.gl/AGLmRC8g9vQDg21Q6
'==================================================


'----------------
' INITIALIZATION
'----------------
include "data_maze2/heightmap_library.n7"
include "s3d.n7"; S3D_SetView(primary, rad(90), 0.1, 5)
set window "Maze 2 - Part 1.Sand Desert",400,200,false,3
set mouse off
set redraw off

'color definition
gray         = [128,128,128]
black        = [0,0,0]
white        = [255,255,255]
red          = [255,0,0]
green        = [0,255,0]
darkgreen    = [0,128,0,120]

' Heightmap and Ground
heightmapImg = loadimage("data_maze2/heightmap.png");hm = CreateHeightmap(heightmapImg, 8)
groundImg    = loadimage("data_maze2/ground.png")

' Camera
camX         = 32   ; camY          = 0 ; camZ      = 32 'position
camYaw       = 0    ; camPitch      = 0                  'rotation
camBobAngle  = 0    ; camBobEffect  = 0                  'when the user moves

' Mummy
mummy = []
mummy[1] = []
mummy[1].img = loadimage("data_maze2/mummy1.png")

' misc initial value
dt = 0.003
map = [] 'little map
map.x = width(primary)-100
map.z = height(primary)-80
map.w = width(heightmapImg)
map.h = height(heightmapImg)
map.r = map.w/2        'radius
map.cx = map.x+map.w/2 'center
map.cz = map.z+map.h/2 'center
map.a  = 0             'angle
pos = [] 'player's position
pos.x = 0
pos.y = 0
pos.z = 0

'-----------
' GAME LOOP
'-----------
while not keydown(KEY_ESCAPE, true)
    '----------
    ' control
    '----------
    ' Rotation
    mdx = mouserelx(); mdy = mouserely()
    camYaw = (camYaw + mdx*45*dt)%360 ; camPitch = min(max(camPitch - mdy*45*dt, -60), 60)
    set mouse width(primary)/2, height(primary)/2
   
    ' Movement
    dx = 0; dz = 0
    if keydown(KEY_SPACE)
        dx = dx + sin(rad(camYaw))
        dz = dz + cos(rad(camYaw))
    endif
    if dx or dz
        camBobAngle = camBobAngle + 500*dt          'when the user moves
        k = dt/sqr(dx*dx + dz*dz)
        camX = camX + k*dx                          'position X                 
        camZ = camZ + k*dz                          'position Z
        camBobEffect = min(camBobEffect + 4*dt, 1)  'when the user moves
    endif
    camY = hm.GetY(camX, camZ) - 0.5                'position Y
    pos.x = str(camX,0,1)
    pos.y = str(camY,0,1)
    pos.z = str(camZ,0,1)   
    map.a = 90-camYaw

    '------------
    ' rendering
    '------------
    ' Fill screen with the fog color.
    set color gray; cls

    ' Rendering Process
    S3D_Clear()
    S3D_SetSorting(S3D_BACK_TO_FRONT)
    S3D_SetDepthBuffer(S3D_Z_BUFFER_WRITE)
    S3D_RotateX(rad(-camPitch))
    S3D_RotateY(rad(-camYaw))
    S3D_Translate(-camX, -camY + 0.04*camBobEffect*sin(rad(camBobAngle)), -camZ)
    S3D_Texture(groundImg)
    S3D_Mesh(hm.mesh, 0)
    S3D_Render()
    S3D_RenderFog(gray[0],gray[1],gray[2],false)
       
    ' Just simple draw image
    set color white
    draw image mummy[1].img, 20,20               
       
    '------------
    ' navigation
    '------------
    set color black
        set caret 0,0; wln "Angle "+camYaw 'camYaw = 0 south, 90 east, 180 north, 270 west
        wln "Position "+pos.x+","+pos.y+","+pos.z
    set color darkgreen ; draw ellipse map.cx,map.cz,map.r,map.r,true
    set color green     
        draw ellipse map.cx,map.cz,map.r,map.r
        draw line    map.cx,map.cz,map.cx+map.r*cos(rad(map.a)),map.cz+map.r*sin(rad(map.a))
    set color red       ; draw ellipse (map.x+int(pos.x)),(map.z+int(pos.z)),2,2,true
    set color white     ; draw ellipse (map.x+int(pos.x)),(map.z+int(pos.z)),2,2
        set caret map.cx-18, map.z-13; wln "North" 
        set caret map.cx-18, map.z+map.h; wln "South"
        set caret map.x-35, map.cz-5; wln "West"
        set caret map.x+map.w+5, map.cz-5; wln "East"
   
    redraw
    wait 1
wend



Attached Files
.zip   maze2.zip (Size: 93.07 KB / Downloads: 5)
Print this item

  Circle-line collision
Posted by: Marcus - 04-16-2024, 03:59 PM - Forum: NaaLaa 7 Code - Replies (9)

I wrote a quick test for how collisions between moving objects (player and enemies) and the static walls should work in that 3d thing I'm working on. In the game/engine I will just check for collisions with walls close to the moving objects (a uniform grid will contain information about which walls passes through each cell). But maybe someone may still find this test useful for their own purposes:

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

lines = []
randomize 11
for i = 1 to 8
    ln = [rnd(640), rnd(480), rnd(640), rnd(480)]
    dx = ln[2] - ln[0]; dy = ln[3] - ln[1]
    ln[6] = sqr(dx*dx + dy*dy)
    ln[4] = dx/ln[6]
    ln[5] = dy/ln[6]
    lines[sizeof(lines)] = ln
next

obj = Object(320, 240, 16)

while not keydown(KEY_ESCAPE, true)
    'obj.x = mousex(); obj.y = mousey()
    if keydown(KEY_LEFT)  obj.x = obj.x - 4
    if keydown(KEY_RIGHT)  obj.x = obj.x + 4
    if keydown(KEY_UP)  obj.y = obj.y - 4
    if keydown(KEY_DOWN)  obj.y = obj.y + 4   
    PushOut(obj, lines)
   
    set color 0, 0, 0
    cls
    set color 255, 255, 255
    DrawLines(lines)
    obj.Draw()
   
    set caret width(primary)/2, 0
    center "Use the arrow keys to move the circle around"
   
    redraw
    fwait 60
wend

function DrawLines(lines)
    foreach ln in lines  draw line ln[0], ln[1], ln[2], ln[3]
endfunc

function Object(x, y, r)
    return [x: x, y: y, r: r, rsqr: r*r,
            Draw: function(); draw ellipse .x, .y, .r, .r, false; endfunc]
endfunc

function PushOut(obj, lines)
    ' Let all lines push the object around a maximum of 10 times. This is not a recommended
    ' approach, just for testing.
    tests = 10
    for i = 1 to tests
        col = false
        foreach ln in lines
            dp = max(0, min(ln[6], (obj.x - ln[0])*ln[4] + (obj.y - ln[1])*ln[5]))
            px = ln[0] + dp*ln[4]; py = ln[1] + dp*ln[5]
            dx = obj.x - px; dy = obj.y - py
            d = dx*dx + dy*dy
            if d < obj.rsqr
                k = 1/sqr(d)
                obj.x = px + dx*k*obj.r
                obj.y = py + dy*k*obj.r
                col = true
            endif
        next
        if not col break
    next
endfunc

This is pretty much how I did it in the GLOOM library for n6 too, if my memory is correct (source code since long gone).

Print this item

  Flappy Bird
Posted by: johnno56 - 04-16-2024, 12:17 PM - Forum: NaaLaa 7 Code - Replies (4)

This is a project I started back on 19th October 2016 using SDLBasic...
Over the years it has been ported to QB64 and RCBasic (Jan 2022)

The game is simple. Left Mouse Button or Space to flap. Fly through the "gaps" in the pipes. Each pipe passed is one point. Warning: The game will speed up gradually (usually after every 5 pipes) to a maximum speed of "8"....


.zip   flappy.zip (Size: 95.22 KB / Downloads: 7)

Be careful... index finger fatigue warning!

(ps: Had to mute the "flapping" sound... so annoying... needs a type of timer mod...)

Print this item

  Pixeli Lander Test
Posted by: johnno56 - 04-15-2024, 12:48 AM - Forum: NaaLaa 7 Code - Replies (5)

Ok. This is a VERY crude Lander test. It uses "pixeli()" for collision with the Landing Pad and normal AABB for the ground...

I would appreciate an examination of how I have implemented the pixeli command and suggest any and all corrections.

Note: The ship can land from beneath the pad... Not an error. The landing pad (except for a concept level) is always on the ground.

The usual controls: Arrow keys.
Note: BOTH landing struts MUST contact the pad.
Watch your landing velocity.


.zip   pixelTest.zip (Size: 70.7 KB / Downloads: 7)

Print this item

  n7 version 24.04.14 released
Posted by: Marcus - 04-14-2024, 10:28 AM - Forum: Announcements - Replies (2)

You can now use 'pixeli(x, y)' or 'pixeli(image_id, x, y)' to get the color of an image's pixel as a single number. You can also use 'set colori' to set the current drawing color using such a number.

If you need to convert RGB or RGBA values to a single number color, you can use functions like these:

Code:
function ToRGB(r, g, b)
    return 255*16777216 + r*65536 + g*256 + b
endfunc

function ToRGBA(r, g, b, a)
    return a*16777216 + r*65536 + g*256 + b
endfunc
 
And to get the RGBA components of a single number color:

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

2024-04-14
Added the 'pixeli' function and 'set colori' command to get and set colors as single numbers

Print this item

  Pixel Color Test
Posted by: johnno56 - 04-11-2024, 08:27 PM - Forum: NaaLaa 7 Questions - Replies (5)

Marcus,

I am still confused in regards to "how" the pixel() command works.

Are you able to explain the output produced? (see attached image)

   

Regards

J

Print this item

  pursuing object
Posted by: aliensoldier - 04-11-2024, 01:51 PM - Forum: NaaLaa 7 Questions - Replies (3)

A question, if I have two objects and one is the player who can move with the keys and the other is the enemy who is stationary in one place on the screen.

The question would be how can I make it so that when the player is close to the enemy he starts chasing the player and if the player moves away the enemy stops chasing him and returns to the starting position.

Print this item

  N6 Lander
Posted by: johnno56 - 04-09-2024, 10:52 PM - Forum: NaaLaa 7 Code - Replies (3)

With all this discussion about Lunar Lander stuff, why not go back to the source, and recreate the original N6 Lander using N7?

Warning: Docking can be a little flaky and keep your eye on that fuel level...


.zip   landerN6.zip (Size: 6.76 KB / Downloads: 6)

ps: Look familiar, Marcus? Wink

Print this item

  The Maze
Posted by: 1micha.elok - 04-09-2024, 09:50 AM - Forum: NaaLaa 7 Code - Replies (15)

THE MAZE
I'm still working on the game, and soon it will be released
Herewith some preview snapshots :

           
click the image to zoom in

Big Grin Big Grin Big Grin

Print this item