Il y a encore beaucoup à faire, et le saut est complètement bogué je le sais mais je compte m'y mettre sérieusement dès qu'il fera trop froid pour aller à la plage !

y'a deux fichiers source.
Voici le 1er :
Code : Tout sélectionner
;- init libs
InitSprite() : InitKeyboard()
IncludeFile"data.pb"
;- constantes
Enumeration
#spr_mario_droite
#spr_mario_marche_droite
#spr_mario_marche_droite2
#spr_mario_saute_droite
#spr_mario_gauche
#spr_mario_marche_gauche
#spr_mario_marche_gauche2
#spr_mario_saute_gauche
#spr_bloc
EndEnumeration
;- structures
Structure tile
x.w
y.w
EndStructure
Structure objet Extends tile
frame.w
vitesse.b
dir_droite.b
anim.w
saut.w
EndStructure
;- variables
Global mario.objet
mario\frame = #spr_mario_droite
mario\x = 64
mario\y = 64
mario\vitesse = 1
mario\dir_droite = 1
mario\anim = 0
mario\saut = 0
;- tableaux
Dim bloc.tile(65)
;- Affichage
OpenScreen(1024, 768, 16, "Mario_PureCode")
TransparentSpriteColor(-1, 255, 0, 255)
;- Sprites
CreateSprite(#spr_mario_droite, 64, 64)
For ligne = 0 To 15
For colonne = 0 To 15
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_droite))
Box(colonne * 4, ligne * 4, 4, 4, couleur) ; 4= facteur de zoom
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_marche_droite, 64, 64)
For ligne = 0 To 15
For colonne = 0 To 15
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_marche_droite))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_marche_droite2, 64, 64)
For ligne = 0 To 15
For colonne = 0 To 15
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_marche_droite2))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_saute_droite, 64, 64)
For ligne = 0 To 15
For colonne = 0 To 15
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_saute_droite))
Box(colonne * 4, ligne * 4, 4, 4, couleur) ; 4= facteur de zoom
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_gauche, 64, 64)
Restore pixel :
For ligne = 0 To 15
For colonne = 15 To 0 Step - 1
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_gauche))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_marche_gauche, 64, 64)
For ligne = 0 To 15
For colonne = 15 To 0 Step - 1
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_marche_gauche))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_marche_gauche2, 64, 64)
For ligne = 0 To 15
For colonne = 15 To 0 Step - 1
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_marche_gauche2))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_mario_saute_gauche, 64, 64)
For ligne = 0 To 15
For colonne = 15 To 0 Step - 1
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(0, 0, 0) : EndIf ; 1 = noir
If pixel = 2 : couleur = RGB(0, 0, 255) : EndIf ; 2 = bleu
If pixel = 3 : couleur = RGB(255, 180, 150) : EndIf ; 3 = peau
If pixel = 4 : couleur = RGB(255, 0, 0) : EndIf ; 4 = rouge
StartDrawing(SpriteOutput(#spr_mario_saute_gauche))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
CreateSprite(#spr_bloc, 64, 64)
For ligne = 0 To 14
For colonne = 0 To 15
Read pixel
If pixel = 0 : couleur = RGB(255, 0, 255) : EndIf ; 0 = transparence
If pixel = 1 : couleur = RGB(240, 120, 10) : EndIf ; 1 = brique
If pixel = 2 : couleur = RGB(250, 210, 190) : EndIf ; 2 = pastel
If pixel = 3 : couleur = RGB(0, 0, 0) : EndIf ; 3 = noir
StartDrawing(SpriteOutput(#spr_bloc))
Box(colonne * 4, ligne * 4, 4, 4, couleur)
StopDrawing()
Next colonne
Next ligne
;- Boucle principale
Repeat
ClearScreen(0, 150, 255)
ExamineKeyboard()
Gosub level :
Gosub move :
DisplayTransparentSprite(mario\frame, mario\x, mario\y)
FlipBuffers(0)
Until KeyboardPushed(#PB_Key_Escape)
End
;- Subroutines
level :
Restore map :
n = 0
For ligne = 0 To 11
For colonne = 0 To 15
Read map
If map
DisplaySprite(#spr_bloc, 64 * colonne, 64 * ligne) ; 64 = taille bloc
bloc(n)\x = colonne * 64
bloc(n)\y = ligne * 64
n + 1
EndIf
Next colonne
Next ligne
Return
move :
If KeyboardPushed(#PB_Key_Right)
If mario\anim > 0 And mario\anim < 40
mario\frame = #spr_mario_marche_droite
EndIf
If mario\anim > 40 And mario\anim < 80
mario\frame = #spr_mario_marche_droite2
EndIf
If mario\anim = 80
mario\anim = 0
EndIf
mario\anim + 1
mario\x + mario\vitesse
mario\dir_droite = 1
; detection de collisions latérales
For n = 0 To 64
If SpriteCollision(mario\frame, mario\x, mario\y, #spr_bloc, bloc(n)\x, bloc(n)\y)
mario\x = bloc(n)\x - 64
mario\frame = #spr_mario_droite
EndIf
Next
EndIf
If KeyboardReleased(#PB_Key_Right)
mario\anim = 0
mario\frame = #spr_mario_droite
EndIf
If KeyboardPushed(#PB_Key_Left)
If mario\anim > 0 And mario\anim < 40
mario\frame = #spr_mario_marche_gauche
EndIf
If mario\anim > 40 And mario\anim < 80
mario\frame = #spr_mario_marche_gauche2
EndIf
If mario\anim = 80
mario\anim = 0
EndIf
mario\anim + 1
mario\x - mario\vitesse
mario\dir_droite = 0
; detection de collisions latérales
For n = 0 To 64
If SpriteCollision(mario\frame, mario\x, mario\y, #spr_bloc, bloc(n)\x, bloc(n)\y)
mario\x = bloc(n)\x + 64
mario\frame = #spr_mario_gauche
EndIf
Next
EndIf
If KeyboardReleased(#PB_Key_Left)
mario\anim = 0
mario\frame = #spr_mario_gauche
EndIf
If KeyboardPushed(#PB_Key_Left) And KeyboardPushed(#PB_Key_right)
mario\frame = #spr_mario_droite
EndIf
;- gravite
mario\y + 1
For n = 0 To 64
If SpriteCollision(mario\frame, mario\x, mario\y, #spr_bloc, bloc(n)\x, bloc(n)\y)
mario\y = bloc(n)\y - 64
mario\saut = 0
If mario\frame = #spr_mario_saute_droite
mario\frame = #spr_mario_droite
EndIf
If mario\frame = #spr_mario_saute_gauche
mario\frame = #spr_mario_gauche
EndIf
EndIf
Next
If KeyboardPushed(#PB_Key_Up)
If mario\dir_droite = 1
mario\frame = #spr_mario_saute_droite
Else
mario\frame = #spr_mario_saute_gauche
EndIf
If mario\saut < 100
mario\y - 2
EndIf
mario\saut + 1
For n = 0 To 64
If SpriteCollision(mario\frame, mario\x, mario\y, #spr_bloc, bloc(n)\x, bloc(n)\y)
mario\y = bloc(n)\y + 64
EndIf
Next
EndIf
Return
Et voilà le fichier data.pb nécessaire (ce sont les sprites et la map)
Code : Tout sélectionner
;- Datasections
DataSection
pixel :
Data.l 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0 ; mario_droite et gauche
Data.l 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0
Data.l 0, 0, 0, 0, 1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