Thank you threedslider,threedslider wrote: Sun Dec 03, 2023 9:53 am Hello Mijikai,
It is awesome your lib !Thank you for sharing
![]()
Can you provide an example of 2D game as 2D platform, please ? I want to make a 2D game platform ^^
Good job and keep it up bro !
i made a very simple example the movement and collision routines are just a quick hack!
But if improved on this can be a good starting point


Code: Select all
EnableExplicit
XIncludeFile "rpix.pbi"
Procedure.i Main()
Protected *rpix.RPIX,*Map.RPIX_SURFACE,*guy.RPIX_SURFACE
Protected.i x,y,j,u,oy,ox
*rpix = rpixWindow(#RPIX_WINDOW_NORMAL,640,512,320,256,#True)
If *rpix
*map = *rpix\BufferSurface();<- create a map sprite from the backbuffer (same size)
*rpix\DrawBox(*map,0,250,320,256,100,#True);<- draw map elements
*rpix\DrawBox(*map,0,200,40,2,100,#True)
*rpix\DrawBox(*map,100,220,40,2,100,#True)
*rpix\DrawBox(*map,150,200,40,2,100,#True)
*rpix\DrawBox(*map,220,200,40,2,100,#True)
*guy = *rpix\SurfaceCreate(8,16);<- create a player sprite
*guy\BufferFill(255);<- make it white (using the grayscale palette entry 255)
*guy\BufferSet(2,4,0);<- draw some eyes on the player sprite
*guy\BufferSet(6,4,0)
x = 100;<- set the players starting position
y = x
Repeat
*rpix\InputUpdate() ;<- handle user input
ox = x;<- safe old player position
oy = y
x + *rpix\InputKeyDown(#VK_RIGHT);<- handle player movement
x - *rpix\InputKeyDown(#VK_LEFT)
If *rpix\InputKeyToggle(#VK_UP) And j = #False;<- handle player jump
u = y;<- from where is the player jumping
j = #True ;<- set jumping to #True
EndIf
If j;<- when jumping do all this...
y - 2
If y = u - 30
j = #False
EndIf
Else
y + 2
EndIf
*map\BufferWrite(0);<- start rendereing (first the map is written/copied to the backbuffer)
If *guy\Test(0,x,y,0,100,#True) And oy <> y And y > oy;<- do some pixel collision detection for the player
y = oy;<- reset the players y position if there is a hit
EndIf
*guy\Draw(0,x,y,#True);<- draw the player
*rpix\DrawText(0,160,16,"USE DIRECTION KEYS TO MOVE AND JUMP!",140,#True);<- draw some text
*rpix\BufferDrawEvent();<- render the backbuffer to the screen
Until *rpix\WindowExit()
*rpix\WindowClose()
EndIf
ProcedureReturn #Null
EndProcedure
End Main()