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: 191
» Forum posts: 1,489

Full Statistics

Online Users
There are currently 133 online users.
» 0 Member(s) | 131 Guest(s)
Bing, Google

Latest Threads
City Fighter
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
04-17-2025, 11:37 PM
» Replies: 7
» Views: 353
RW3
Forum: NaaLaa 7 Code
Last Post: Marcus
04-11-2025, 05:22 AM
» Replies: 3
» Views: 269
ugBASIC! Good BASIC!
Forum: Programming
Last Post: luwal
04-04-2025, 11:35 PM
» Replies: 6
» Views: 640
Happy Birthday
Forum: Everything else
Last Post: johnno56
04-03-2025, 10:52 PM
» Replies: 3
» Views: 420
Pool - Cue Sports (Simple...
Forum: NaaLaa 7 Code
Last Post: johnno56
04-03-2025, 06:41 PM
» Replies: 3
» Views: 436
Nintendo Switch 2
Forum: Everything else
Last Post: johnno56
04-03-2025, 05:41 AM
» Replies: 2
» Views: 323
Pixel Editor
Forum: NaaLaa 7 Code
Last Post: kevin
03-31-2025, 06:52 PM
» Replies: 12
» Views: 1,292
Shell
Forum: NaaLaa 7 Questions
Last Post: johnno56
03-29-2025, 08:11 AM
» Replies: 3
» Views: 394
Rectangle (simple physics...
Forum: NaaLaa 7 Code
Last Post: johnno56
03-25-2025, 07:26 PM
» Replies: 3
» Views: 548
Some textures
Forum: Everything else
Last Post: 1micha.elok
03-23-2025, 10:24 AM
» Replies: 5
» Views: 697

 
  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

  Pixel Collision
Posted by: johnno56 - 04-09-2024, 09:08 AM - Forum: NaaLaa 7 Questions - Replies (11)

I figured that I might try some 'old school' collision detection...

The concept is... A falling box. An area to land on. Using the 'pixel()' command, instruct the box to stop, as it "hits" the ground.

In this example, I am testing the pixel below the box's left bottom edge. (I have placed a reference pixel under the box at the same "y" co-ordinate.)

Press SPACE to drop...

Code:
' Open a window and enable double buffering.
set window "Pixel Collision", 640, 480
set redraw off

visible Box = [255, 255, 0, 64]
visible BoxW = 32
visible BoxH = 48
visible BoxX = (width(primary) - BoxW) / 2
visible BoxY = 0
visible vSpeed = 0
visible drop = false

visible ground = [0, 255, 0]

do

    set color 0, 0, 0
    cls
   
    Update()
    Draw()
   
    redraw
    fwait 30
   
until keydown(KEY_ESCAPE, true)

function Update()
    '   vSpeed
    if keydown(KEY_SPACE, true)     drop = true
    if drop = true  vSpeed = vSpeed + 0.03
   
    '   Box
    BoxY = BoxY + vSpeed
   
    '   Pixel Collision
    if pixel(BoxX, BoxY + BoxH) = ground
        vSpeed = 0
    endif
   
    '   Just in case 'pixel' fails... lol
    if BoxY > height(primary)
        vSpeed = 0
        wait 1000
        end
    endif
endfunc

function Draw()
    '   Ground
    set color ground
    draw rect 0, 460, 640, 20, 0
   
    '   Box
    set color Box
    draw rect BoxX, BoxY, BoxW, BoxH, 0
   
    '   Pixel
   
    '   This indicator pixel is drawn one pixel below the box center.
    '   The actual pixel being tested is below the left corner of the box.
    set color 255, 0, 255
    draw pixel BoxX + 15, BoxY + BoxH
endfunc

Unfortunately this did not work... "Read the manual", I hear you say... "pixel(x,y) Returns the color at position (x, y) as an array [r, g, b, a] with RGBA intensities in the range [0 .. 255].

I am hoping that my programing skills are the source of the problem otherwise this maybe another "can of worms".... sorry...

Print this item

  n7 version 24.04.07 released
Posted by: Marcus - 04-07-2024, 02:13 PM - Forum: Announcements - Replies (10)

I'm taking a break from working on the s3d (simple 3d) library. It's included in this release, and now I want to see if it's possible to make a game using it. It is quite slow now, but I promise you that it will get faster when I implement better ways to do hidden surface removal and optimize all the sloppy code. I wrote some documentation for the library yesterday (S3D.pdf) and there are some examples under n7/examples/s3d_library, but you really need to have some basic knowledge about 3D programming and maybe played around with legacy OpenGL to use this thing. As I mentioned earlier, it's not meant to be a game engine - that comes later.

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

2024-04-07

  • Added the s3d library
  • Hopefully fixed an issue with the tilemap editor when running through wine

Print this item

  Tilemap Editor Linux
Posted by: johnno56 - 04-03-2024, 10:15 PM - Forum: NaaLaa 7 Questions - Replies (15)

I have found a slight problem with the TM on Linux. If you look at the GUI there is a cosmetic difference.

   

The cosmetics do not bother me... The lower 4 radio buttons cannot be selected. At the moment, it is not really an issue, as I seem to be using only the to top 3 buttons. Just to confirm the problem, I ran N7 TM in Windows 7 via Virtualbox (refer to image) and the Win7 version looked fine.

As I am only starting to work my way through the Editor, I am not requiring the use of the "angled" collision detection yet... but you never know.... Moo Ha Ha Ha...

As I stated earlier, I am not concerned about the cosmetic differences, but those lower buttons could end being an issue...

J

Print this item

  Questions about old games
Posted by: johnno56 - 03-28-2024, 11:16 PM - Forum: NaaLaa 7 Questions - Replies (28)

I was going through some old drives and noticed that I have a tendency to concentrate on "old" games... Cannot figure out why... lol

I found an old text-based Moon Lander from the late 70's... and got to thinking... (Ok. Stop laughing...) I have seen "many" versions of this game for most machines that I have owned in the past... For nostalgia, I was thinking of trying my hand at an N7 version... Which got me to thinking again... (Really. Still laughing? *sigh*)

I am pretty clear on the game elements... except for one... Collision... 

Oh. I know how to do simple AABB and Circular collisions but, when it comes to colliding with the "landscape", I am at a loss as to finding an efficient method of detection.

Most of my "programming" has been using Basic. Unless the "Basic" has a sprite collision system built in - detecting collision has been either by AABB, Circular or Colour detection. The latter would work for the "landscape" but it is SO inefficient... I cannot use AABB or Circular as the landscape is irregularly shaped...  Oh. text was SO much easier... lol

I have always enjoyed the "old stuff"... It is probably because of the way I think... (Nope. I am not going to say it...)

Any suggestions, or constructive criticisms, are always appreciated.

J

(PS: I hope that everyone will have a great and safe Easter break...)

Print this item

  Uncorrectly read file
Posted by: 1micha.elok - 03-23-2024, 11:30 AM - Forum: NaaLaa 7 Questions - Replies (6)

Question
Case 1 : I think ... [for...next] is not the best way to read text file
Case 2 : I think this is the best way, but [do..until frln(f) = "unset"] gives unexpectedly output

Please advice me what is the best way to read the whole text file ?
Thank you.

Code:
set window "readfile",400,400

f = openfile("story.txt")

'Case 1
'correctly read file
for i = 0 to 21
    wln frln(f)
    i = i + 1
next

'Case 2
'uncorrectly read file
do
    wln frln(f)
until frln(f)="unset"

free file f

temp=rln()



Attached Files
.n7   readfile.n7 (Size: 256 bytes / Downloads: 2)
.txt   story.txt (Size: 147 bytes / Downloads: 3)
Print this item