un petit test de manette,pour pure miga c'est pas encore au point.
Code : Tout sélectionner
;Manette Pure Miga
EnableExplicit
;- Initialisations
If InitSprite()=0 Or InitKeyboard()=0
MessageRequester("Probleme","Initialisations impossibles",0)
End
EndIf
#ecran = 0
#L =640
#H = 480
Enumeration
#stick_centre
#stick_gauche
#stick_droite
#stick_haut
#stick_bas
#socle
#bouton_stick
#player
#scanline
#b1
EndEnumeration
Structure Scanlines
scan.i
Scanx.i
Scany.i
EndStructure
Structure barre
Bposx.i
Bposy.i
Bcouleur.i
vitesse.i
EndStructure
OpenWindow(#ecran,0,0,#L,#H,"test stick",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#ecran),0,0,#L,#H)
Global quitter,event,stickx,sticky,sx1,sy1,sx2,sy2,Sbx,sby,Shx,Shy,soclex,socley,boutonx,boutony
Global aff_stick,aff_bouton,Px,Py,intro
Global NewList Scanlines.Scanlines(),Scanx,Scany,colonne
Global Bposx,Bposy,event,i,Rouge1.f,Vert1.f,Bleu1.f,Rouge2.f,Vert2.f,Bleu2.f,Drouge.f,Dvert.f,Dbleu.f
Global ecran_image,ecran,ecran_posx,ecran_posy
Global Dim barres.barre(32)
quitter = 0
;position départ
stickx = 200
sticky = 200
;droite
sx1 =250
sy1 = 200
;gauche
sx2 = 250
sy2 = 200
;haut
Shx = 200
Shy = 200
;bas
Sbx = 200
Sby = 270
;socle
soclex =200
socley = 200
;bouton
boutonx = 260
boutony = 200
aff_stick = 1
aff_bouton = 1
Px = 250
Py = 50
Procedure quitter()
If quitter = 0
quitter = KeyboardPushed(#PB_Key_Escape)
EndIf
EndProcedure
Procedure stick_centre()
CreateSprite(#stick_centre,120,190)
StartDrawing(SpriteOutput(#stick_centre))
Box(95,165,10,24,RGB(155,155,155))
Box(97,165,6,40,RGB(15,255,255))
Box(98,165,2,40,RGB(105,180,220))
Circle(100,155,17,RGB(102,0,0))
Circle(100,155,12,RGB(122,0,0))
Circle(100,153,8,RGB(155,15,0))
Circle(98,147,4,RGB(255,50,0))
Circle(99,147,2,RGB(255,100,0))
StopDrawing()
EndProcedure
Procedure stick_droite()
CreateSprite(#stick_droite,120,190)
StartDrawing(SpriteOutput(#stick_droite))
Box(95,165,10,24,RGB(155,155,155))
Box(97,165,6,40,RGB(15,255,255))
Box(98,165,2,40,RGB(105,180,220))
Circle(100,150,17,RGB(102,0,0))
Circle(100,150,12,RGB(122,0,0))
Circle(100,148,8,RGB(155,15,0))
Circle(98,144,4,RGB(255,50,0))
Circle(99,144,2,RGB(255,100,0))
StopDrawing()
EndProcedure
Procedure stick_gauche()
CreateSprite(#stick_gauche,120,190)
StartDrawing(SpriteOutput(#stick_gauche))
Box(95,165,10,24,RGB(155,155,155))
Box(97,165,6,40,RGB(15,255,255))
Box(98,165,2,40,RGB(105,180,220))
Circle(100,150,17,RGB(102,0,0))
Circle(100,150,12,RGB(122,0,0))
Circle(100,148,8,RGB(155,15,0))
Circle(98,144,4,RGB(255,50,0))
Circle(99,144,2,RGB(255,100,0))
StopDrawing()
EndProcedure
Procedure stick_haut()
CreateSprite(#stick_haut,120,190)
StartDrawing(SpriteOutput(#stick_haut))
Box(95,165,10,24,RGB(155,155,155))
Box(97,165,6,40,RGB(15,255,255))
Box(98,165,2,40,RGB(105,180,220))
Circle(100,150,15,RGB(102,0,0))
Circle(100,150,15,RGB(122,0,0))
Circle(100,148,6,RGB(155,15,0))
Circle(98,144,3,RGB(255,50,0))
Circle(99,144,1,RGB(255,100,0))
StopDrawing()
EndProcedure
Procedure stick_bas()
CreateSprite(#stick_bas,120,190)
StartDrawing(SpriteOutput(#stick_bas))
Box(95,115,10,24,RGB(155,155,155))
Box(97,115,6,30,RGB(15,255,255))
Box(98,115,2,30,RGB(105,180,220))
Circle(100,135,17,RGB(102,0,0))
Circle(100,135,12,RGB(122,0,0))
Circle(100,130,8,RGB(155,15,0))
Circle(98,130,4,RGB(255,50,0))
Circle(99,130,2,RGB(255,100,0))
StopDrawing()
EndProcedure
Procedure socle()
CreateSprite(#socle,200,200)
StartDrawing(SpriteOutput(#socle))
RoundBox(83,176,35,22,35,22,RGB(100,100,100))
RoundBox(88,179,25,15,25,15,RGB(90,90,90))
;RoundBox(91,180,18,10,18,10,RGB(0,35,0))
StopDrawing()
EndProcedure
Procedure bouton_stick()
CreateSprite(#bouton_stick,200,200)
StartDrawing(SpriteOutput(#bouton_stick))
RoundBox(83,176,35,22,35,22,RGB(100,100,100))
RoundBox(88,178,25,18,25,8,RGB(255, 0, 0))
RoundBox(91,180,18,10,18,10,RGB(255,255,255))
RoundBox(93,181,15,8,15,8,RGB(255, 0, 0))
StopDrawing()
EndProcedure
Procedure bouton_app()
CreateSprite(#player,200,200)
StartDrawing(SpriteOutput(#player))
Circle(150,134,5,RGB(0,100,0))
StopDrawing()
EndProcedure
;-scanline
Procedure scanline()
CreateSprite(#scanline,620,15,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#scanline))
Box(0,0,120,5,RGB(55,55,55))
StopDrawing()
EndProcedure
Procedure affiche_scanlines()
ForEach scanlines()
ZoomSprite(scanlines()\scan,3320,5)
DisplayTransparentSprite(scanlines()\scan,scanlines()\scanx,scanlines()\scany,45)
Next
EndProcedure
Procedure ligne()
CreateSprite(#B1,400,32)
;couleur de départ,couleur d'arrivé,différence
Rouge1.f = 0
Vert1.f = 0
Bleu1.f = 0
;couleur d'arrivé
Rouge2.f =5/0.008
Vert2.f = 55/0.08
Bleu2.f = 55/0.08
;delta
Drouge.f = ((Rouge2+Rouge1))
Dvert.f = ((Vert2+Vert1))
Dbleu.f = ((Bleu2+Bleu1))
StopDrawing()
EndProcedure
Procedure barre_couleur()
With barres(i)
For i = 0 To 31
\Bposx = 120
\Bposy = 25
\Bcouleur = RGB(Rouge1,Vert1,Bleu1)
Rouge1 - Drouge
Vert1 - Dvert
Bleu1 - Dbleu
Next
EndWith
EndProcedure
Procedure affiche_couleur()
For Bposy = 0 To 31
StartDrawing(SpriteOutput(#b1))
Box(Bposx*3, Bposy, Bposx+180, bposy+5, RGB(Rouge1, Vert1, Bleu1))
Rouge1 + Drouge
Vert1 + Dvert
Bleu1 + Dbleu
StopDrawing()
Next Bposy
EndProcedure
Procedure affiche_decrunching()
For i = 0 To 31
ZoomSprite(#b1,885,250)
DisplayTransparentSprite(#B1,barres(i)\Bposx,barres(i)\Bposy,barres(i)\Bcouleur)
Next i
EndProcedure
;----------- affiche texte ----------------
Procedure affichetexte()
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(250,438,"Manette Pure Miga: ",RGB(255,255,0))
DrawText(450,438,"Player X: "+Str(Px),RGB(255,255,0))
DrawText(450,458,"Player Y : "+Str(Py),RGB(0,255,0))
StopDrawing()
EndProcedure
Procedure affiche_loading()
StartDrawing(ScreenOutput())
DrawText(250,50,"Initialisation : ok ",RGB(255,255,0))
StopDrawing()
EndProcedure
Procedure affiche_loading2()
StartDrawing(ScreenOutput())
DrawText(250,100,"Sprite : ok ",RGB(0,255,0))
StopDrawing()
EndProcedure
Procedure affiche_loading3()
StartDrawing(ScreenOutput())
DrawText(250,150,"Decrunching : ok ",RGB(255,255,0))
StopDrawing()
EndProcedure
Procedure affiche_loading4()
StartDrawing(ScreenOutput())
DrawText(250,200,"Stick : ok ",RGB(0,255,0))
StopDrawing()
EndProcedure
Procedure affiche_loading5()
StartDrawing(ScreenOutput())
DrawText(250,250,"Test Stick : ok ",RGB(125,255,255))
StopDrawing()
EndProcedure
SpriteQuality(#PB_Sprite_BilinearFiltering)
stick_centre()
stick_droite()
stick_gauche()
stick_haut()
stick_bas()
socle()
bouton_stick()
bouton_app()
scanline()
ligne()
barre_couleur()
;-scanline
For colonne = 0 To 182
AddElement(Scanlines())
With Scanlines()
\scan = CopySprite(#scanline,#PB_Any)
\Scany = colonne * 4
EndWith
Next
;--------- boucle ----------
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event=0
;--------------------------
FlipBuffers()
ClearScreen(0)
ExamineKeyboard()
affichetexte()
DisplayTransparentSprite(#socle,soclex,socley)
If aff_stick = 1
DisplayTransparentSprite(#stick_centre,stickx,sticky)
EndIf
If aff_bouton = 1
bouton_stick()
DisplayTransparentSprite(#bouton_stick,boutonx,boutony+1)
DisplayTransparentSprite(#bouton_stick,boutonx,boutony-2)
EndIf
;--------- touches clavier --------------
; If KeyboardPushed(#PB_Key_Right)
; aff_stick=0
; RotateSprite(#stick_droite,sx1/8,#PB_Absolute)
; DisplayTransparentSprite(#stick_droite,sx1+5,sy1-8)
; Px + 1
; EndIf
;
; If KeyboardReleased(#PB_Key_Right)
; aff_stick = 1
; EndIf
;
; If KeyboardPushed(#PB_Key_Left)
; aff_stick = 0
; RotateSprite(#stick_gauche,sx2-280,#PB_Absolute)
; DisplayTransparentSprite(#stick_gauche,sx2-91,sy2+33)
; PX -1
; EndIf
;
; If KeyboardReleased(#PB_Key_Left)
; aff_stick = 1
; EndIf
; If KeyboardPushed(#PB_Key_Down)
; aff_stick = 0
; DisplayTransparentSprite(#stick_bas,Sbx,Sby)
; Py +1
; EndIf
;
; If KeyboardReleased(#PB_Key_Down)
; aff_stick = 1
; EndIf
;
; If KeyboardPushed(#PB_Key_Up)
; aff_stick = 0
; DisplayTransparentSprite(#stick_haut,Shx,Shy)
; Py - 1
; EndIf
;
; If KeyboardReleased(#PB_Key_Up)
; aff_stick = 1
; EndIf
;
; If KeyboardPushed(#PB_Key_Space)
; DisplayTransparentSprite(#bouton_stick,boutonx,boutony)
; EndIf
;
; If KeyboardReleased(#PB_Key_Space)
; aff_bouton = 1
; Px = 150
; Py = 100
; EndIf
;------------------------------------
;debut test
intro + 1
aff_stick = 1
aff_bouton = 1
Select intro
Case 50 To 150
affiche_loading()
Case 150 To 250
affiche_loading()
affiche_loading2()
Case 250 To 350
affiche_loading()
affiche_loading2()
affiche_loading3()
Case 350 To 450
affiche_loading()
affiche_loading2()
affiche_loading3()
affiche_loading4()
Case 450 To 550
affiche_loading()
affiche_loading2()
affiche_loading3()
affiche_loading4()
affiche_loading5()
Case 650 To 750
DisplayTransparentSprite(#player, Px,Py)
Px = 150
Py = 100
Case 750 To 850
DisplayTransparentSprite(#player, Px,Py)
aff_stick = 0
aff_bouton = 1
RotateSprite(#stick_gauche,sx2-280,#PB_Absolute)
DisplayTransparentSprite(#stick_gauche,sx2-91,sy2+33)
PX -1
Case 850 To 950
DisplayTransparentSprite(#player, Px,Py)
Case 950 To 1150
DisplayTransparentSprite(#player, Px,Py)
aff_stick=0
RotateSprite(#stick_droite,sx1/8,#PB_Absolute)
DisplayTransparentSprite(#stick_droite,sx1+5,sy1-8)
Px + 1
Case 1150 To 1250
DisplayTransparentSprite(#player, Px,Py)
Case 1250 To 1350
DisplayTransparentSprite(#player, Px,Py)
aff_stick = 0
DisplayTransparentSprite(#stick_bas,Sbx,Sby)
Py +1
Case 1350 To 1450
DisplayTransparentSprite(#player, Px,Py)
Case 1450 To 1650
DisplayTransparentSprite(#player, Px,Py)
aff_stick = 0
DisplayTransparentSprite(#stick_haut,Shx,Shy)
Py - 1
Case 1650 To 1750
DisplayTransparentSprite(#player, Px,Py)
Case 1750 To 1770
aff_bouton = 0
DisplayTransparentSprite(#bouton_stick,boutonx,boutony)
Case 1780 To 1950
aff_bouton=1
affiche_couleur()
affiche_decrunching()
EndSelect
quitter()
affiche_scanlines()
Until quitter Or event = #PB_Event_CloseWindow
End