Well, I fixed up the code, it should work but there are still some bugs, the collisions with platforms are iffy, and I can't find a way to delete a solid with the right click, I also don't know how to show the FPS.
`Set up the sync rate
sync on : sync rate 60
`Load up the images
set image colorkey 255, 255, 255
global player_img as byte = 1 : load image "Player.bmp", 1
global platform_img as byte = 2 : load image "Platform.bmp", 2
`Set up types
type object
spr as word
X as float
Y as float
Xspeed as float
Yspeed as float
jump_force as float
gravity as float
on_floor as boolean
endtype
`Set up sprites
dim platform(300) as object
player as object
player.spr = 1
player.X = 100
player.Y = 100
player.jump_force = -7
player.gravity = 0.3
sprite player.spr, player.X, player.Y, player_img
`Engine booleans
global p_count as dword = 0
global space_down as boolean = 0
`*********************************************
`***************** Main Loop *****************
`*********************************************
DO
show_text()
horizontal_movement()
vertical_movement()
test_collisions()
update_sprites()
keyboard()
place_platform()
SYNC
LOOP
`*********************************************
`************* End Main Loop *****************
`*********************************************
`-------------------------------------
function show_text()
cls
text 10, 10, "Platforms: " + str$(p_count)
text 10, 20, "X-Speed: " + str$(player.Xspeed)
text 10, 30, "Y-Speed: " + str$(player.Yspeed)
text 10, 40, "On Floor: " + str$(player.on_floor)
endfunction
`----------------------------------------
function horizontal_movement()
`Read input
if leftkey() = 1 and rightkey() = 0 then dec player.Xspeed, 0.5
if rightkey() = 1 and leftkey() = 0 then inc player.Xspeed, 0.5
`No input
if (leftkey() = 0 and rightkey() = 0) or (leftkey() = 1 and rightkey() = 1)
if player.Xspeed >= -0.5 and player.Xspeed <= 0.5 then player.Xspeed = 0
if player.Xspeed < -0.25 then inc player.Xspeed, 0.25
if player.Xspeed > 0.25 then dec player.Xspeed, 0.25
endif
`Limit the speed
if player.Xspeed > 1.5 then player.Xspeed = 1.5
if player.Xspeed < -1.5 then player.Xspeed = -1.5
endfunction
`-----------------------------------------
function vertical_movement()
`Makes the player jump
if spacekey() = 1 and space_down = 0 and player.on_floor = 1
player.Yspeed = player.jump_force
player.on_floor = 0
endif
`Drops the player if he lets go of the space key
if spacekey() = 0 and player.Yspeed < 0 then player.Yspeed = player.Yspeed / 2
`Apply gravity
if player.on_floor = 0 then inc player.Yspeed, player.gravity
if player.Yspeed > 4 then player.Yspeed = 4
if player.Yspeed < -4
inc player.Y, -4
else
inc player.Y, player.Yspeed
endif
endfunction
`-----------------------------------------
function test_collisions()
`Floor collisions
if player.Y + image height(player_img) >= screen height()
player.on_floor = 1
player.Yspeed = 0
player.Y = screen height() - image height(player_img)
endif
`Platform collisions
if p_count > 0
global side_push as boolean = 0
for n = 1 to p_count
if sprite collision(player.spr, n + 1) = 1
if player.Yspeed > 0 `Go down
if player.Y + image height(player_img) - player.Yspeed <= platform(n).Y and side_push = 0
stop_fall(n)
else
stop_wall(n)
endif
endif
if player.Yspeed = 0 `No speed
if player.Y + image height(player_img) = platform(n).Y
else
stop_wall(n)
endif
endif
if player.Yspeed < 0 `Go up
if player.Y - player.Yspeed >= platform(n).Y + image height(platform_img) and side_push = 0
player.Yspeed = 4
else
stop_wall(n)
endif
endif
endif
next n
endif
endfunction
`-----------------------------------------
function keyboard()
if spacekey() = 1 then space_down = 1
if spacekey() = 0 then space_down = 0
endfunction
`-----------------------------------------
function update_sprites()
inc player.X, player.Xspeed
inc player.Y, player.Yspeed
if player.X < 0 then player.X = 0
if player.X + sprite width(player_img) > screen width() then player.X = screen width() - sprite width(player_img)
sprite player.spr, player.X, player.Y, player_img
endfunction
`----------------------------------------
function place_platform()
if mouseclick() = 1
`Local variables
x_pos = 0
y_pos = 0
`Get position of platform
S = image height(platform_img)
for n = 0 to screen width() / S
if mousex() >= n * S and mousex() < (n * S) + S
x_pos = n * S
endif
next n
for m = 0 to screen height() / S
if mousey() >= m * S and mousey() < (m * S) + S
y_pos = m * S
endif
next m
`Check if platforms already exists there
add as boolean = 1
if p_count > 0
for n = 1 to p_count
if x_pos = platform(n).X and y_pos = platform(n).Y then add = 0
next n
endif
`Add platform
if add = 1 and mouseclick() = 1
inc p_count, 1
platform(p_count).X = x_pos
platform(p_count).Y = y_pos
platform(p_count).spr = p_count + 1
sprite platform(p_count).spr, platform(p_count).X, platform(p_count).Y, platform_img
endif
endif
endfunction
`---------------------------------------------------------------------
function stop_fall(p)
player.on_floor = 1
player.Yspeed = 0
player.Y = platform(p).Y - image height(player_img)
endfunction
`-----------------------------------------------------------------------
function stop_wall(p)
side_push = 1
if player.X > platform(p).X and player.Xspeed < 0
player.X = platform(p).X + image width(player_img) : endif
if player.X < platform(p).X and player.Xspeed > 0
player.X = platform(p).X - image width(player_img) : endif
endfunction
Anyways, thanks for the advice.