Log In  
Follow
leo6127
thisisatinygame
by leo6127

so I made a physics engine
and then I improved it
edit: and again
edit 2: moving this to blogs nobody looks at the subsections
yay
let's call it thisisatinyphysicsengine for no flipping reason :b
anyway here is a demo
(note that this is not a completed game, it is just a proof)
yes the old code is in there I don't have time to change it

Cart #tiatpe_demo-1 | 2026-08-27 | Code ▽ | Embed ▽ | No License
1


make collidable objects flag 0
call upp(player) inside update
player should look like:

 p = {
  x = 16,
  y = 16,
  vx = 0,
  vy = 0,
  a = 0,
  f = 0.85,
  s = 0.5,
  g = 0.3,
  gr = false,
  h = 7, -- don't ask why its 7 idk it just works if anyone knows math pls let me know

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=195338#p)
1
0 comments



Simple physics engine I made :b
I am planning on adding support for more types of platforms
Give both the player and the platforms flag 0
If u wanna use a different flag change the fget function inside of n()
To use call upp(p) inside of ur update loop
The player dict should look like:

p = {
  x  = 32,  
  y  = 32,
  vx = 0,  
  vy = 0,   
  w  = 7,    -- coords start at 0
  h  = 7,    -- coords start at 0
  g  = 0.6,  -- gravity
  f  = 0.85  -- friction
}

Tweak to ur liking
Engine code:

function n(x,y)return fget(mget(flr(x/8),flr(y/8)),0)end 
function upp(p)
p.vy+=p.g 
p.vx*=p.f 
p.x+=p.vx 
if p.vx>0 then 
if(n(p.x+p.w,p.y)or n(p.x+p.w,p.y+p.h))p.x=flr((p.x+p.w)/8)*8-p.w-.01p.vx=0 
elseif p.vx<0 then 
if(n(p.x,p.y)or n(p.x,p.y+p.h))p.x=flr(p.x/8)*8+8p.vx=0 
end 
p.y+=p.vy 
if p.vy>0 then 
if(n(p.x,p.y+p.h)or n(p.x+p.w,p.y+p.h))p.y=flr((p.y+p.h)/8)*8-p.h-.01p.vy=0
elseif p.vy<0 then 
if(n(p.x,p.y)or n(p.x+p.w,p.y))p.y=flr(p.y/8)*8+8p.vy=0 
end 
end

Credits to shrinko8

1 comment



this is a tiny game, hope you like it :)
up is jump left/right is move, down is checkpoint
CHANGELOG
v0.1
added music
checkpoint appears as a blue square
v0.2
i did it i managed to use the plat engene from https://www.lexaloffle.com/bbs/?tid=154935 after so much debugging
credits to AtomicPico
v0.3
oops removed music on v.02

if you get annoyed by trapping yourself with checkpoints thats just a skill issue

Cart #hunudimabi-3 | 2026-02-14 | Code ▽ | Embed ▽ | No License
1

1
11 comments