Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 37
» Latest member: Ludwig
» Forum threads: 203
» Forum posts: 1,543
Full Statistics
|
Online Users |
There are currently 149 online users. » 0 Member(s) | 147 Guest(s) Applebot, Yandex
|
|
|
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
|
|
|
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.
|
|
|
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...
|
|
|
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
|
|
|
|