Hi, I'm back and I modified the collision, and variables even more.
Little glitch's still occur on the corners sometimes, but it does the job.
The collision works in all 4 directions now left right top bottom.
And I made a 2D array for the tiles... not so sure that it was the best idea, it can be a little confusing.
Mario style, except without Mario.
SCR_X = 800 : SCR_Y = 600
set display mode SCR_X,SCR_Y,16 `Adjusts screen resolution
set window layout 0,0,0 : maximize window `Makes full screen
randomize Timer() `randomizes the placement of the platforms
sync on : sync rate 60 `Sets sync to 60 fps
Rem Player Variables
PL_X# = SCR_X/2
PL_Y# = 16
PL_X_Speed# = 0
PL_Y_Speed# = 0
PL_SizeX = 25
PL_SizeY = 25
PL_X_Slide# = 0.5
Rem more player variables
MovementForce# = 0.5
MovementMax# = 6.0
JumpForce# = 8.0
GravityForce# = 0.2
PL_On_Platform = 0
Rem Tile variable and array
Tile_All = 30
`TileData Info: 0 = X_Position 1 = Y_Position 2 = X Size 3 = Y Size
dim TileData(Tile_All,3)
TileData(0,0) = SCR_X/2 `Base Tile X Position
TileData(0,1) = SCR_Y-16 `Base Tile Y Position
TileData(0,2) = SCR_X `Base Tile X Size
TileData(0,3) = 32 `Base Tile Y Size
Rem Creates all of the tile platforms
For i = 1 to Tile_All
TileData(i,0) = rnd(19)*32+96 `Tile X Position
TileData(i,1) = rnd(15)*32+48 `Tile Y Position
TileData(i,2) = (rnd(3)+1)*32 `Tile X Size
TileData(i,3) = 32 `Tile Y Size
next i
Rem Creates the background
Box 0,0,SCR_X,SCR_Y,rgb(100,0,50),rgb(200,200,200),rgb(10,40,110), rgb(255,0,255)
Get Image 1,0,0,SCR_X,SCR_Y
ink 0,0 `black color
Rem Main Loop
do
Paste Image 1,0,0 `Draws the background
Rem The Jump Button (upkey, or spacekey)
if PL_On_Platform = 1 and upkey() = 1 or spacekey() = 1 and PL_Y_Speed# = 0
PL_Y_Speed# = -JumpForce#
PL_On_Platform = 0
endif
Rem Arrow keys Right and Left
if rightkey() = 1 and PL_X_Speed# < MovementMax# then inc PL_X_Speed#,MovementForce#
if leftkey() = 1 and PL_X_Speed# > -MovementMax# then dec PL_X_Speed#,MovementForce#
Rem X-Speed Control
for i = 1 to 3
Num# = 1.0/(10.0^i)/PL_X_Slide#
if PL_X_Speed# > Num# then dec PL_X_Speed#,Num#
if PL_X_Speed# < -Num# then inc PL_X_Speed#,Num#
next i
if PL_X_Speed# > 0 then dec PL_X_Speed#,0.0001
if PL_X_Speed# < 0 then inc PL_X_Speed#,0.0001
Rem Move the player on the X-Axis
inc PL_X#,PL_X_Speed#
if PL_X# < 0 then inc PL_X#,SCR_X
if PL_X# > SCR_X then dec PL_X#,SCR_X
Rem Move the player on the Y-Axis
inc PL_Y#,PL_Y_Speed#
inc PL_Y_Speed#,GravityForce#
if PL_Y_Speed# > 1 then PL_On_Platform = 0
Rem Draw all platforms and detect collision
For i = 0 to Tile_All
Rem Draw The Platforms
box TileData(i,0)-TileData(i,2)/2,TileData(i,1)-TileData(i,3)/2,TileData(i,0)+TileData(i,2)/2,TileData(i,1)+TileData(i,3)/2,RGB(48,31,16),RGB(192,126,64),RGB(48,31,16),RGB(192,126,64)
Rem Platform Collision Y
if PL_X#-PL_SizeX/2+5 < TileData(i,0)+TileData(i,2)/2 and PL_X#+PL_SizeX/2-5 > TileData(i,0)-TileData(i,2)/2
if PL_Y#-PL_SizeY/2 < TileData(i,1)+TileData(i,3)/2 `hit head on platform
if PL_Y#-PL_SizeY/2 > TileData(i,1)
PL_Y# = TileData(i,1)+TileData(i,3)/2+PL_SizeY/2
PL_Y_Speed# = 0
endif
endif
if PL_Y#+PL_SizeY/2 > TileData(i,1)-TileData(i,3)/2 and PL_Y#+PL_SizeY/2 < TileData(i,1) `Land on top of platform
PL_Y# = TileData(i,1)-TileData(i,3)/2-PL_SizeY/2
PL_Y_Speed# = 0
if upkey() = 0 and spacekey() = 0 then PL_On_Platform = 1
endif
endif
`Platform Collision X
if PL_Y#-PL_SizeY/2+5 < TileData(i,1)+TileData(i,3)/2 and PL_Y#+PL_SizeY/2-5 > TileData(i,1)-TileData(i,3)/2
if PL_X#-PL_SizeX/2 < TileData(i,0)+TileData(i,2)/2 `hit head
if PL_X#-PL_SizeX/2 > TileData(i,0)
PL_X# = TileData(i,0)+TileData(i,2)/2+PL_SizeX/2
PL_X_Speed# = 0
endif
endif
if PL_X#+PL_SizeX/2 > TileData(i,0)-TileData(i,2)/2 `touch down
if PL_X#+PL_SizeX/2 < TileData(i,0)
PL_X# = TileData(i,0)-TileData(i,2)/2-PL_SizeX/2
PL_X_Speed# = 0
endif
endif
endif
next i
Rem Draw the player
Box PL_X#-PL_SizeX/2,PL_Y#-PL_SizeY/2,PL_X#+PL_SizeX/2,PL_Y#+PL_SizeY/2
Box PL_X#-PL_SizeX/2+SCR_X,PL_Y#-PL_SizeY/2,PL_X#+PL_SizeX/2+SCR_X,PL_Y#+PL_SizeY/2 `Player Right
Box PL_X#-PL_SizeX/2-SCR_X,PL_Y#-PL_SizeY/2,PL_X#+PL_SizeX/2-SCR_X,PL_Y#+PL_SizeY/2 `Player Left
sync `updates the screen
loop `end of the main loop
end `end of the program
I don't think that you will need sin, cos, tan, etc. trigonometry stuffs, unless you need to make a program that involves firing projectile at a specific angle.
Then what you need to do is take that 360 sprite motion code I told you about so you can get the starting angle of the projectile,
and then add some gravity, and adjust the velocity of the projectile, and finally create a giant robot for the projectile to collide with.
Make sure that there is a big explosion. You could even make random projectile explosion effects too, that would be cool.
Good luck if that what you need to do, but it looks like all you need is to adjust sync rate, and some variables.
I like games, and stuff.