I am a fan of Naalaa, you know it
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 ...
logo_N7.png (Size: 8.96 KB / Downloads: 24)
click the image to zoom in
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.
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?
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.
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
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
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.
#win32
constant WIN_W = 640, WIN_H = 480
set window "Sleepy Tunnel", WIN_W, WIN_H
set redraw off
aa = 0
while not keydown(KEY_ESCAPE, true)
aa = aa + 0.05
zoffset = (zoffset + 0.001)%0.01
set color 0, 0, 0
cls
set color 255, 255, 255
maxz = 0.1 + 150*0.01
for i = 150 to 0
z = 0.1 + i*0.01 - zoffset
s = 50/z
x = cos(z*5 + aa)*(z - 0.1)*50
y = sin(z*5 + aa)*(z - 0.1)*25
intens = 255 - 255*z*1.5/maxz
set color intens*0.5, intens, intens*0.75
draw pixel WIN_W/2 + x/z + cos(rad(0))*s, WIN_H/2 + y/z + sin(rad(0))*s
a = 15
while a <= 360
draw line to WIN_W/2 + x/z + cos(rad(a))*s, WIN_H/2 + y/z + sin(rad(a))*s
a = a + 15
wend
next
redraw
fwait 60
wend
Possible use in games, such as
- Space Invaders, Gargoyle Attack
- Tetris
Code:
'==========================================
' SIMPLE SCALING AND ROTATING
'
'Possible use in games, such as
'- Space Invaders, Gargoyle Attack
'- Tetris
'
'Limitation
'Rotate : only multiplication of 90 degree
'==========================================
'----------------
' INITIALIZATION
'----------------
set window "Pixel Art", 150, 150, false,4
set redraw off
'Pause and wait until SPACE BAR is pressed, ESCAPE to quit
set caret width(primary)/2, height(primary)-20
center "SPACE BAR"; redraw
do;wait 1;if keydown(KEY_ESCAPE,true) end;until keydown(KEY_SPACE,true)
if scale < 10 then
scale = scale + 1
else
scale = 1
endif
if rotate < 3 then
rotate = rotate + 1
else
rotate = 0
endif
free image Sprite.img 'free image from memory
loop
'-----------
' FUNCTIONS
'-----------
function Scale(data,s)
img = createimage(8*s,8*s); set image img
for y = 0 to 7
for x = 0 to 7
if data[y][x] then
set color cGreen
else
set color cBlack
endif
draw rect x*s,y*s,s,s,1
next
next
set image primary; return img
endfunc
function Rotate(data,s,r)
img = createimage(8*s,8*s); set image img
for y = 0 to 6
for x = 0 to 6
if data[y][x] then
set color cGreen
else
set color cBlack
endif
'(a,b) = center point of rotation
'(x,y) is rotated into (m,n)
'd = angle of rotation in radian
'm = cos(d)*(x-a)-sin(d)*(y-b)+a
'n = sin(d)*(x-a)+cos(d)*(y-b)+b
a = 3
b = 3
d = r*90*(22/7)/180
m = (round((cos(d)*(x-a))-(sin(d)*(y-b))+a))
n = (round((sin(d)*(x-a))+(cos(d)*(y-b))+b))
draw rect m*s,n*s,s,s,1
next
next
set image primary; return img
endfunc
function TitleScreen()
set caret width(primary)/2,5
center "Scaling and"
center "Rotating"
set caret width(primary)/2, height(primary)-20
center "Press ENTER"
redraw
do;wait 1;until keydown(KEY_RETURN,true)
endfunc
Here's a pool game that I have been working on. You can play against another player, or the computer.
I've tried to include playing hints that show up as you play - there's no time pressure, so you can take the time to read these as they appear in the lower part of the screen.
The main control is the mouse or trackpad. When it is your turn to play, press AND HOLD DOWN the left mouse button to lift the pool cue. You can then position the cue by using the mouse, while keeping the mouse button pressed down. The further away from the white ball the mouse goes, the more powerful the shot will be. When you are happy with the mouse position, release the mouse button to take the shot.
There's no image files needed, so you can just run the n7 file from the zip, or use the executable.