Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 37
» Latest member: Ludwig
» Forum threads: 194
» Forum posts: 1,495
Full Statistics
|
Online Users |
There are currently 57 online users. » 0 Member(s) | 54 Guest(s) Applebot, Bing, Google
|
Latest Threads |
Backspace Key
Forum: NaaLaa 7 Questions
Last Post: Marcus
10 hours ago
» Replies: 3
» Views: 53
|
BASIC games, Pascal games...
Forum: Everything else
Last Post: luwal
04-23-2025, 02:57 AM
» Replies: 0
» Views: 23
|
C64 Game Maker v1.5.5
Forum: Programming
Last Post: luwal
04-22-2025, 04:55 AM
» Replies: 0
» Views: 31
|
City Fighter
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
04-17-2025, 11:37 PM
» Replies: 7
» Views: 545
|
RW3
Forum: NaaLaa 7 Code
Last Post: Marcus
04-11-2025, 05:22 AM
» Replies: 3
» Views: 349
|
ugBASIC! Good BASIC!
Forum: Programming
Last Post: luwal
04-04-2025, 11:35 PM
» Replies: 6
» Views: 717
|
Happy Birthday
Forum: Everything else
Last Post: johnno56
04-03-2025, 10:52 PM
» Replies: 3
» Views: 444
|
Pool - Cue Sports (Simple...
Forum: NaaLaa 7 Code
Last Post: johnno56
04-03-2025, 06:41 PM
» Replies: 3
» Views: 476
|
Nintendo Switch 2
Forum: Everything else
Last Post: johnno56
04-03-2025, 05:41 AM
» Replies: 2
» Views: 347
|
Pixel Editor
Forum: NaaLaa 7 Code
Last Post: kevin
03-31-2025, 06:52 PM
» Replies: 12
» Views: 1,400
|
|
|
Backspace Key |
Posted by: 1micha.elok - 04-23-2025, 03:22 AM - Forum: NaaLaa 7 Questions
- Replies (3)
|
 |
Hi
I am working with some keydown event codes, but I can't seem to find the key code for the backspace key.
Could you kindly advise me? Thank you!
Code: #win32
set window "KEYDOWN",200,100,false,4
set redraw off
while not keydown(KEY_ESCAPE)
set color 0,0,0
cls
set color 255,255,255
set caret 10,10
if keydown(KEY_INSERT) wln "Insert"
if keydown(KEY_DELETE) wln "Delete"
if keydown(KEY_HOME) wln "Home"
if keydown(KEY_END, true) wln "End"
if keydown(KEY_PAGE_UP) wln "Page Up"
if keydown(KEY_PAGE_DOWN) wln "Page Down"
'if keydown(KEY_BACKSPACE) wln "Backspace"
redraw
fwait 10
wend
|
|
|
RW3 |
Posted by: Marcus - 04-10-2025, 03:36 PM - Forum: NaaLaa 7 Code
- Replies (3)
|
 |
I'm doing "a micha" here and post about a future game, so that you don't think I've died.
Progress is really slow (I'm very busy). But here are three really weird robot enemies from rw3 (robowack 3). I recorded them before drawing their "final" textures and after doing so. I always start with a dummy texture, where I mark all different areas of the model.
<video width="320" height="240" controls><source src="https://naalaa.com/tmp/squares.mp4" type="video/mp4">Your browser does not support the video tag.</video>
<video width="320" height="240" controls><source src="https://naalaa.com/tmp/foots.mp4" type="video/mp4">Your browser does not support the video tag.</video>
<video width="320" height="240" controls><source src="https://naalaa.com/tmp/thumper.mp4" type="video/mp4">Your browser does not support the video tag.</video>
They may look kind, even cute. But they're evil af.
|
|
|
Pool - Cue Sports (Simple Physics) |
Posted by: 1micha.elok - 04-03-2025, 05:54 AM - Forum: NaaLaa 7 Code
- Replies (3)
|
 |
click the image to zoom in
Pool - Cue Sports
Code: '====================================
'
' Pool - Cue Sports (Simple Physics)
'
'====================================
'
' * Friction:
' Friction is simulated by multiplying the velocity (vx and vy) by a FRICTION.
' This gradually reduces the speed of the ball until it comes to a stop.
'
' * Elastic Collisions:
' When two balls collide, their velocities are adjusted based on
' the laws of conservation of momentum and energy.
' The collision is resolved by decomposing the velocities into components
' along the collision normal and tangent vectors.
' The normal components of the velocities are swapped between the two balls,
' while the tangent components remain unchanged.
'
' * Wall Collisions:
' When a ball hits a wall, its velocity along the direction perpendicular
' to the wall is reversed and scaled by the ELASTICITY.
' This simulates energy loss during the collision.
'
' * Cue Stick Mechanics:
' The cue stick's direction is determined by the angle
' between the cue ball and the mouse position.
' The velocity of the cue ball is calculated using trigonometry:
' vx = power * cos(angle) and vy = power * sin(angle).
'
' * Stopping Condition:
' A ball is considered stopped if its velocity is below a threshold.
' This prevents the simulation from continuing indefinitely due to very small residual velocities.
#win32
' Constants
constant FRICTION = 0.99 ' Friction reduces ball speed over time
constant ELASTICITY = 0.99 ' Elasticity determines how much energy is conserved during collisions
' Cue
visible Cue = []
' Ball
visible Ball = [] ' Array to store all balls (cue ball + others)
Ball.r = 10 ' Ball radius
Ball.m = 15 ' Maximum power for shooting the cue ball
Ball.n = 9 ' The number of the balls
for i = 0 to Ball.n
Ball[i] = []
Ball[i].vx = 0
Ball[i].vy = 0
next
'----------------
' MAIN LOOP
'----------------
init_game()
while not keydown(KEY_ESCAPE, true)
' Event handling
if keydown(KEY_SPACE, true) and Cue.aiming then
' Shoot the cue ball by applying velocity based on the cue angle and power
Ball[0].vx = Cue.power * cos(Cue.angle) ' X velocity = power * cosine(angle)
Ball[0].vy = Cue.power * sin(Cue.angle) ' Y velocity = power * sine(angle)
Cue.aiming = false ' Exit aiming mode after shooting
endif
' Calculate aim angle based on mouse position
if Cue.aiming then
Cue.power = Ball.m
else
Cue.power = 0 ' Reset power if not aiming
endif
' Check if all balls have stopped moving
all_stopped = true
for i = 0 to Ball.n
if Ball[i].vx <> 0 or Ball[i].vy <> 0 then
all_stopped = false ' At least one ball is still moving
break
endif
next
if all_stopped then Cue.aiming = true ' Allow aiming again if all balls have stopped
' Update ball positions and handle collisions
update_Balls()
' Draw the game
draw_game()
' Wait for next frame
redraw
fwait 60
wend
'-------------
' FUNCTIONS
'-------------
' Initialize the game
function init_game()
' Set up the game window
set window "Pool Game with Physics", 800, 400, false
set redraw off
randomize time()
' Create balls and initialize their positions and colors
Ball[0].x = 100 ; Ball[0].y = rnd(50,height()-50) ; Ball[0].c = [255, 255, 255] ' Cue ball (white)
for i = 1 to Ball.n
Ball[i].x = rnd(50,width()-50)
Ball[i].y = rnd(50,height()-50)
Ball[i].c = [rnd(100,200), rnd(50,200), rnd(50,200)]
next
' Initialize aiming variables
Cue.angle = 0 ' Initial angle of the cue stick
Cue.power = 0 ' Initial power of the shot
Cue.aiming = true ' Start in aiming mode
endfunc
' Update ball positions and handle collisions
function update_Balls()
for i = 0 to Ball.n
' Apply friction to simulate resistance on the table
Ball[i].vx = Ball[i].vx * FRICTION
Ball[i].vy = Ball[i].vy * FRICTION
' Update position based on velocity
Ball[i].x = Ball[i].x + Ball[i].vx
Ball[i].y = Ball[i].y + Ball[i].vy
' Bounce off walls (elastic collision with boundaries)
if Ball[i].x - Ball.r < 0 or Ball[i].x + Ball.r > 800 then
Ball[i].vx = -Ball[i].vx * ELASTICITY ' Reverse X velocity and apply elasticity
endif
if Ball[i].y - Ball.r < 0 or Ball[i].y + Ball.r > 400 then
Ball[i].vy = -Ball[i].vy * ELASTICITY ' Reverse Y velocity and apply elasticity
endif
' Stop the ball if velocity is very low (to prevent infinite sliding)
if abs(Ball[i].vx) < 0.5 then Ball[i].vx = 0
if abs(Ball[i].vy) < 0.5 then Ball[i].vy = 0
next
' Handle collisions between balls (elastic collisions)
for i = 0 to Ball.n-1
for j = i + 1 to Ball.n
' Calculate distance between the centers of two balls
dx = Ball[j].x - Ball[i].x
dy = Ball[j].y - Ball[i].y
distance = sqr(dx * dx + dy * dy)
' If the distance is less than or equal to the sum of their radii, they are colliding
if distance <= Ball.r * 2 then
' Move the balls apart to prevent sticking
overlap = (Ball.r * 2 - distance) / 2
nx = dx / distance
ny = dy / distance
Ball[i].x = Ball[i].x - overlap * nx
Ball[i].y = Ball[i].y - overlap * ny
Ball[j].x = Ball[j].x + overlap * nx
Ball[j].y = Ball[j].y + overlap * ny
' Calculate the normal vector (direction of collision)
nx = dx / distance
ny = dy / distance
' Calculate the tangent vector (perpendicular to the normal)
tx = -ny
ty = nx
' Project velocities onto the normal and tangent vectors
dp_self_n = Ball[i].vx * nx + Ball[i].vy * ny ' Dot product for ball i
dp_other_n = Ball[j].vx * nx + Ball[j].vy * ny ' Dot product for ball j
' Swap normal components of velocities (conservation of momentum)
Ball[i].vx = Ball[i].vx + (dp_other_n - dp_self_n) * nx
Ball[i].vy = Ball[i].vy + (dp_other_n - dp_self_n) * ny
Ball[j].vx = Ball[j].vx + (dp_self_n - dp_other_n) * nx
Ball[j].vy = Ball[j].vy + (dp_self_n - dp_other_n) * ny
endif
next
next
endfunc
' Draw the game
function draw_game()
' Clear screen
set color 0, 0, 0
cls
' Draw balls
for i = 0 to Ball.n
set color Ball[i].c[0], Ball[i].c[1], Ball[i].c[2]
draw ellipse Ball[i].x, Ball[i].y, Ball.r, Ball.r, true
next
' Draw cue stick and trajectory if aiming
if Cue.aiming then
mx = mousex() ' Mouse X position
my = mousey() ' Mouse Y position
dx = mx - Ball[0].x ' Difference in X between mouse and cue ball
dy = my - Ball[0].y ' Difference in Y between mouse and cue ball
Cue.angle = atan2(dy, dx) ' Calculate angle using arctangent
' Draw white circle around the cue ball to reflect cue power
set color 255, 255, 255
draw ellipse Ball[0].x, Ball[0].y, Ball.r + Cue.power, Ball.r + Cue.power, false
' Simulate and draw cue ball trajectory
set color 255, 255, 255
px = Ball[0].x
py = Ball[0].y
vx = Cue.power * cos(Cue.angle)
vy = Cue.power * sin(Cue.angle)
prev_x = px
prev_y = py
t = 0
for steps = 1 to 100
px = px + vx
py = py + vy
' Bounce off walls
if px - Ball.r < 0 or px + Ball.r > width() then
vx = -vx * ELASTICITY
t = t + 1
endif
if py - Ball.r < 0 or py + Ball.r > height() then
vy = -vy * ELASTICITY
t = t + 1
endif
if t > 1 then break 'limit only 2 trajectory lines
' Draw trajectory segment
draw line int(prev_x), int(prev_y), int(px), int(py)
prev_x = px
prev_y = py
next
endif
endfunc
Simple Physics in Naalaa
- Pool - Cue Sports
https://naalaa.com/forum/thread-222.html
Inspired by "A game of pool by Kevin"
https://naalaa.com/forum/thread-87.html
- Rectangle
https://naalaa.com/forum/thread-210.html
- Primitive Angry Bird
https://naalaa.com/forum/thread-205.html
- Bridge
https://naalaa.com/forum/thread-206.html
|
|
|
Happy Birthday |
Posted by: 1micha.elok - 04-01-2025, 06:52 AM - Forum: Everything else
- Replies (3)
|
 |
Sixty-nine years, a journey so vast,
A life full of wisdom, love, and joy to last.
If today’s your birthday, Johnno, let joy unfold,
With laughter, stories, and memories gold
Johnno’s birthday today, is it true?
Or just a prank—an April fool’s coup?
Cake or a trick, what’s on the plate?
Blow out the candles… or take the bait?
|
|
|
Pixel Editor |
Posted by: kevin - 03-29-2025, 06:27 PM - Forum: NaaLaa 7 Code
- Replies (12)
|
 |
Hi,
Attached is a project that I have actually managed to persevere with, so that it is nearly finished. It's yet another picture/tileset/character designer - there are many of these available to download, all of which will be more complete, and more polished, but I have just wanted to make this for my own enjoyment .
I've included 2 things that I haven't been able to find elsewhere:
1 - the functionality to save finished images as both png files and text files. The text files are there to include in N7 files, so that the images can be generated within the program, rather than having to include png files in your projects. I'm using a variation of some code that Marcus provided for this, and there is an example program to illustrate.
2 - to the lower right of the screen is a button that can be used to test your tileset (to make sure that the tiles fit together correctly), before saving it.
I've added some pop up hints to explain what most of the buttons do, but if you have any questions, please ask.
A quick explanation of what you need to do:
1 - choose the image size in pixels (max is 64 * 64) in the top right of the screen. There are some pre-sets available also.
2 - Press the "start drawing" button - this is important, and I keep forgetting this step!
3 - Draw in the main frame, using the brush options to the right. Colours can be changed below the main frame, from the colour palette (other paletts are available to load, or you can make and save your own).
4 - New frames can be added using the button to the left. If you have more than one frame, the active one is shown with a red bar to the left. If you are drawing an animated sprite, the animation can be previewed in the bottom left of the screen.
5 - When ready, save the frames as png or text files using the green buttons to the bottom right. There are also options here to load and edit previous png files, or png files that have been created in different programs.
There is other functionality in the program, which hopefully is self-expanatory.
I've not been able to test this as much as I would like, so please let me know what issues you find. I have tested it up to 8 * 32pixel * 32pixel frames (8000 active pixels) and it works fine, albeit a little slow - this is something that I am till working on.
Pixel Editor 2 - published v4.zip (Size: 1.73 MB / Downloads: 5)
|
|
|
|