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.
I am curious as to "how" your SFX program actually generates tones. For instance: Most Music Notation software relies on a "soundfont" (database of stored samples) to play various instruments but usually require the use of a midi compatible sound card... Are you using a 'secret' method (similar to KFC's herbs and spices) to access the midi port?... Perhaps a little magic or 'slight of hand'? Just curious...
This is a simple side scroller. Collect as many "stars" as you can. It stars off slow, but as your score increases, so does your speed. But, if you miss a star, you will lose a life....
Mouse controlled (vertical only) - Note: The sounds were created by Marcus's SFX library....
For those who are patient enough... post your final scores.... lol
Here comes a new release with the online high-score library (ohs), updated since I posted it in a thread a while ago, and the sfx library.
2024-02-16
The compiler and the generated programs are from now and on 64 bit. libgcc_s_dw2-1.dll is no longer required for the programs to run. ibwinpthread-1.dll and libportaudio.dll are still required but have been replaced with 64 bit versions
Added the sfx library for creating sound effects with two examples in examples/sfx_library
Added the ohs library for online high-score lists with two examples in examples/ohs_library
Added some programs by members of the naalaa forum to examples/other
I think a horizontal bar is necessary so that when the code is very wide it can be moved horizontally comfortably.
I mention this because when creating the scenarios in the platform game that I am making, the scenario is a list and I have not been able to make it very long because I had to move with the keyboard arrows from left to right and when I reached the end I returned to the beginning.
And it was very tiresome to have to move around with the keys again.