UP
Publié : sam. 06/mars/2021 11:42
Bonjour,
Personne ne sait ?
Merci à qui pourras me répondre.
Passez un bon week-end.
Personne ne sait ?
Merci à qui pourras me répondre.
Passez un bon week-end.
Code : Tout sélectionner
InitSprite()
If InitSound()
sound= 1
EndIf
InitKeyboard()
If InitJoystick()
joystick = 1
EndIf
;OnErrorResume()
Procedure DrawTextXY(text.s, x.w, y.w)
StartDrawing(ScreenOutput())
DrawingMode(1)
BackColor(RGB(0,0,0))
FrontColor(RGB(255, 255, 255))
DrawText(x,y,text)
StopDrawing()
EndProcedure
IncludePath #PB_Compiler_Home + "snakes-master\"
DataSection ; ********* a includebinary file bigger .exe but noone can steal stuff :)
body:
IncludeBinary "sprites\body.bmp"
head1:
IncludeBinary "sprites\head_1.bmp"
head2:
IncludeBinary "sprites\head_2.bmp"
head3:
IncludeBinary "sprites\head_3.bmp"
head4:
IncludeBinary "sprites\head_4.bmp"
body2:
IncludeBinary "sprites\body2.bmp"
head21:
IncludeBinary "sprites\head2_1.bmp"
head22:
IncludeBinary "sprites\head2_2.bmp"
head23:
IncludeBinary "sprites\head2_3.bmp"
head24:
IncludeBinary "sprites\head2_4.bmp"
body3:
IncludeBinary "sprites\body3.bmp"
head31:
IncludeBinary "sprites\head3_1.bmp"
head32:
IncludeBinary "sprites\head3_2.bmp"
head33:
IncludeBinary "sprites\head3_3.bmp"
head34:
IncludeBinary "sprites\head3_4.bmp"
body4:
IncludeBinary "sprites\body4.bmp"
head41:
IncludeBinary "sprites\head4_1.bmp"
head42:
IncludeBinary "sprites\head4_2.bmp"
head43:
IncludeBinary "sprites\head4_3.bmp"
head44:
IncludeBinary "sprites\head4_4.bmp"
body5:
IncludeBinary "sprites\body5.bmp"
head51:
IncludeBinary "sprites\head5_1.bmp"
head52:
IncludeBinary "sprites\head5_2.bmp"
head53:
IncludeBinary "sprites\head5_3.bmp"
head54:
IncludeBinary "sprites\head5_4.bmp"
body6:
IncludeBinary "sprites\body6.bmp"
head61:
IncludeBinary "sprites\head6_1.bmp"
head62:
IncludeBinary "sprites\head6_2.bmp"
head63:
IncludeBinary "sprites\head6_3.bmp"
head64:
IncludeBinary "sprites\head6_4.bmp"
body7:
IncludeBinary "sprites\body7.bmp"
head71:
IncludeBinary "sprites\head7_1.bmp"
head72:
IncludeBinary "sprites\head7_2.bmp"
head73:
IncludeBinary "sprites\head7_3.bmp"
head74:
IncludeBinary "sprites\head7_4.bmp"
body8:
IncludeBinary "sprites\body8.bmp"
head81:
IncludeBinary "sprites\head8_1.bmp"
head82:
IncludeBinary "sprites\head8_2.bmp"
head83:
IncludeBinary "sprites\head8_3.bmp"
head84:
IncludeBinary "sprites\head8_4.bmp"
body9:
IncludeBinary "sprites\body9.bmp"
head91:
IncludeBinary "sprites\head9_1.bmp"
head92:
IncludeBinary "sprites\head9_2.bmp"
head93:
IncludeBinary "sprites\head9_3.bmp"
head94:
IncludeBinary "sprites\head9_4.bmp"
food1:
IncludeBinary "sprites\food1.bmp"
food2:
IncludeBinary "sprites\food2.bmp"
food3:
IncludeBinary "sprites\food3.bmp"
food4:
IncludeBinary "sprites\food4.bmp"
food5:
IncludeBinary "sprites\food5.bmp"
misc1:
IncludeBinary "sprites\mystery.bmp"
sound0:
IncludeBinary "sound\item1.wav"
sound1:
IncludeBinary "sound\item2.wav"
sound2:
IncludeBinary "sound\item3.wav"
sound50:
IncludeBinary "sound\music_A.wav"
sound51:
IncludeBinary "sound\music_B.wav"
sound52:
IncludeBinary "sound\music_C.wav"
sound53:
IncludeBinary "sound\music_D.wav"
EndDataSection
#SGreen = 0
#SYellow = 5
#SOrange = 10
#SBlue = 15
#STeal = 20
#SRed = 25
#SPurple = 30
#SGhost = 35
#Shippy = 40
CatchSound(0, ?sound0)
CatchSound(1, ?sound1)
CatchSound(2, ?sound2)
CatchSound(50, ?sound50)
CatchSound(51, ?sound51)
CatchSound(52, ?sound52)
CatchSound(53, ?sound53)
Gosub Menu
If FullScreen = #True
If OpenScreen(screenX, screenY, 16, "Snakes")
Else
MessageRequester("Snakes","Unable To open DirectX 7.0 Or later!",#MB_ICONERROR)
EndIf
Else
If OpenWindow(0, 200, 200, screenX, screenY, "Snakes", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget| #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(0),0,0,screenX,screenY,1,10,10)
Else
MessageRequester("Snakes","Unable To open DirectX 7.0 Or later!",#MB_ICONERROR)
EndIf
EndIf
Structure head ; not really neccessary since theres only one head.. but maybe for multiplayer mode
x.w
y.w
direction.b ; 1 up 2 right 3 down 4 left
length.w
EndStructure
Structure body
x.w
y.w
age.w
EndStructure
NewList body.body()
NewList body2.body()
Structure food
image.b ; this is soley for the purpose of expanding the food variety
x.w
y.w
life.w
EndStructure
NewList food.food()
;- NewGame
NewGame:
CatchSprite(0, ?body)
CatchSprite(1, ?head1)
CatchSprite(2, ?head2)
CatchSprite(3, ?head3)
CatchSprite(4, ?head4)
CatchSprite(5, ?body2)
CatchSprite(6, ?head21)
CatchSprite(7, ?head22)
CatchSprite(8, ?head23)
CatchSprite(9, ?head24)
CatchSprite(10, ?body3)
CatchSprite(11, ?head31)
CatchSprite(12, ?head32)
CatchSprite(13, ?head33)
CatchSprite(14, ?head34)
CatchSprite(15, ?body4)
CatchSprite(16, ?head41)
CatchSprite(17, ?head42)
CatchSprite(18, ?head43)
CatchSprite(19, ?head44)
CatchSprite(20, ?body5)
CatchSprite(21, ?head51)
CatchSprite(22, ?head52)
CatchSprite(23, ?head53)
CatchSprite(24, ?head54)
CatchSprite(25, ?body6)
CatchSprite(26, ?head61)
CatchSprite(27, ?head62)
CatchSprite(28, ?head63)
CatchSprite(29, ?head64)
CatchSprite(30, ?body7)
CatchSprite(31, ?head71)
CatchSprite(32, ?head72)
CatchSprite(33, ?head73)
CatchSprite(34, ?head74)
CatchSprite(35, ?body8)
CatchSprite(36, ?head81)
CatchSprite(37, ?head82)
CatchSprite(38, ?head83)
CatchSprite(39, ?head84)
CatchSprite(40, ?body9)
CatchSprite(41, ?head91)
CatchSprite(42, ?head92)
CatchSprite(43, ?head93)
CatchSprite(44, ?head94)
CatchSprite(50, ?food1)
CatchSprite(51, ?food2)
CatchSprite(52, ?food3)
CatchSprite(53, ?food4)
CatchSprite(54, ?food5)
If lvlSound > 49
PlaySound(lvlsoundnew)
EndIf
moved = 0
head.head\length = 3
head.head\x = 32*2
head.head\y = 32*4
head.head\direction = 2
headimage = 2
moved2 = 0
head2.head\length = 3
head2.head\x = 32*15
head2.head\y = 32*7
head2.head\direction = 4
headimage2 = 4
GameSpeed.f = 35 - StartSpeed
GameSpeed2.f = 35 - StartSpeed
delay = GameSpeed
Delay2 = GameSpeed2
score.l = 0
score2.l = 0
For k = 32 To head.head\length*32 Step 32
AddElement(body())
body()\x = head\x-k
body()\y = head\y
body()\age = k/32
Next
For k = 1 To MaxFood
AddElement(food())
food()\image = 50 + Random(FoodItems)
food()\x = Random(19)*32
food()\y = Random(14)*32
Next
;- Main Loop
Repeat
If FullScreen = #False
If WindowID(0)
Event = WindowEvent()
If Event
Delay(10)
EndIf
EndIf
EndIf
ClearScreen(RGB(0,0,0))
Gosub ExamineKeyboard
Gosub Food
Delay - 1
If Delay < 1
Delay = GameSpeed
Gosub MoveSnake
EndIf
Delay2 - 1
If Delay2 < 1
Delay2 = GameSpeed2
If player = 2
Gosub MoveSnake2
EndIf
EndIf
Gosub Draw
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
End
ElseIf FullScreen = #False And event = #PB_Event_CloseWindow
End
EndIf
ForEver
;- ExamineKeyboard
ExamineKeyboard:
ExamineKeyboard()
If moved = 0 ; 1 up 2 right 3 down 4 left
If KeyboardPushed(#PB_Key_Up) And head\direction <> 3
moved = 1
head\direction = 1
headimage = 1
ElseIf KeyboardPushed(#PB_Key_Right) And head\direction <> 4
moved = 1
head\direction = 2
headimage = 2
ElseIf KeyboardPushed(#PB_Key_Down) And head\direction <> 1
moved = 1
head\direction = 3
headimage = 3
ElseIf KeyboardPushed(#PB_Key_Left) And head\direction <> 2
moved = 1
head\direction = 4
headimage = 4
ElseIf joystick = 1 And playerjoystick = 1
ExamineJoystick(0)
If JoystickAxisY(0)=-1 And head\direction <> 3
moved = 1
head\direction = 1
headimage = 1
ElseIf JoystickAxisX(0)=1 And head\direction <> 4
moved = 1
head\direction = 2
headimage = 2
ElseIf JoystickAxisY(0)=1 And head\direction <> 1
moved = 1
head\direction = 3
headimage = 3
ElseIf JoystickAxisX(0)=-1 And head\direction <> 2
moved = 1
head\direction = 4
headimage = 4
EndIf
EndIf
EndIf
If player = 2 ; 1 up 2 right 3 down 4 left
If moved2 = 0
If KeyboardPushed(#PB_Key_W) And head2\direction <> 3
moved2 = 1
head2\direction = 1
headimage2 = 1
ElseIf KeyboardPushed(#PB_Key_D) And head2\direction <> 4
moved2 = 1
head2\direction = 2
headimage2 = 2
ElseIf KeyboardPushed(#PB_Key_S) And head2\direction <> 1
moved2 = 1
head2\direction = 3
headimage2 = 3
ElseIf KeyboardPushed(#PB_Key_A) And head2\direction <> 2
moved2 = 1
head2\direction = 4
headimage2 = 4
ElseIf joystick = 1 And playerjoystick = 2
ExamineJoystick(0)
If JoystickAxisY(0)=-1 And head2\direction <> 3
moved2 = 1
head2\direction = 1
headimage2 = 1
ElseIf JoystickAxisX(0)=1 And head2\direction <> 4
moved2 = 1
head2\direction = 2
headimage2 = 2
ElseIf JoystickAxisY(0)=1 And head2\direction <> 1
moved2 = 1
head2\direction = 3
headimage2 = 3
ElseIf JoystickAxisX(0)=-1 And head2\direction <> 2
moved2 = 1
head2\direction = 4
headimage2 = 4
EndIf
EndIf
EndIf
EndIf
Repeat ; may "little" pause procedure
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Space) ;pause
If Paused = 0
Gosub Draw
DrawTextXY("PAUSE",ScreenX/2-50,ScreenY/2)
FlipBuffers()
Paused = 1
Else
Paused = 0
EndIf
EndIf
Until paused = 0
If joystick = 1
If JoystickButton(0,10)
paused = 1
pausecounter = 20
Gosub Draw
DrawTextXY("PAUSE",ScreenX/2-50,ScreenY/2)
FlipBuffers()
EndIf
Repeat
ExamineJoystick(0)
If pausecounter < 0
If joystick = 1
If JoystickButton(0,1) Or JoystickButton(0,2) Or JoystickButton(0,3) Or JoystickButton(0,4) Or JoystickButton(0,5) Or JoystickButton(0,6) Or JoystickButton(0,7) Or JoystickButton(0,8)
paused = 0
pausecounter = 20
EndIf
EndIf
Else
pausecounter - 1
EndIf
Until paused = 0
EndIf
DisplayTransparentSprite(headimage,head\x,head\y)
Return
;- Food
Food:
If ListSize(food()) < MaxFood
AddElement(food())
food()\image = 50 + Random(FoodItems)
food()\life = 500 + Random(100)
If player =1
food()\image = 50
Else
k = Random(33)
If k < 11
food()\image = 50
ElseIf k >= 11 And k < 17
food()\image = 51
ElseIf k >= 17 And k < 23
food()\image = 52
ElseIf k >= 23 And k < 27
food()\image = 53
ElseIf k >= 27
food()\image = 54
EndIf
EndIf
food()\x = Random((screenX-32)/32)*32
food()\y = Random((screenY-32)/32)*32
EndIf
ResetList(food())
While NextElement(food())
If head\x = food()\x And head\y = food()\y
If food()\image = 50
head\length + 1
Score + 10
If player = 1
GameSpeed -(1/4)
If gameSpeed < 3
GameSpeed = 3
EndIf
EndIf
PlaySound(0, 0)
ElseIf food()\image = 51
head2\length - (Random(1)+1)
Score + 10
If head2\length < 1
playerWin = 1
Gosub GameOver
EndIf
PlaySound(1, 0)
ElseIf food()\image = 52
If player = 1
GameSpeed - 1
Else
gameSpeed - 3
EndIf
If GameSpeed < 3
GameSpeed = 3
EndIf
Score + 10
PlaySound(2, 0)
ElseIf food()\image = 53
head\length - (Random(1)+1)
Score - 10
If head\length <1
playerWin = 1
Gosub GameOver
EndIf
PlaySound(0, 0)
ElseIf food()\image = 54
GameSpeed + 3
If GameSpeed > 40
GameSpeed = 40
EndIf
Score + 10
PlaySound(2, 0)
EndIf
DeleteElement(food())
EndIf
Wend
If player = 2
ResetList(food())
While NextElement(food())
If head2\x = food()\x And head2\y = food()\y
If food()\image = 50
head2\length + 1
Score2 + 10
PlaySound(0, 0)
ElseIf food()\image = 51
Score2 + 10
head\length - (Random(1)+1)
If head\length < 1
playerWin = 2
Gosub GameOver
EndIf
PlaySound(1, 0)
ElseIf food()\image = 52
GameSpeed2 - 3
If GameSpeed2 < 3
GameSpeed2 = 3
EndIf
Score2 + 10
PlaySound(2, 0)
ElseIf food()\image = 53
head2\length - (Random(1)+1)
Score2 - 10
If head2\length <1
playerWin = 2
Gosub GameOver
EndIf
PlaySound(0, 0)
ElseIf food()\image = 54
GameSpeed2 + 3
If GameSpeed2 > 40
GameSpeed2 = 40
EndIf
Score2 + 10
PlaySound(2, 0)
EndIf
DeleteElement(food())
EndIf
Wend
EndIf
Return
;- MoveSnake 1
MoveSnake:
playerWin = 1 ; if it goes to gameover in this routine player 1 had to of won
AddElement(body())
body()\x = head\x
body()\y = head\y
body()\age = 1
If player = 2
If head\x = head2\x And head\y = head2\y
playerWin = 0
Gosub GameOver
EndIf
EndIf
If head\direction = 1
head\y - 32
ElseIf head\direction = 2
head\x + 32
ElseIf head\direction = 3
head\y + 32
ElseIf head\direction = 4
head\x - 32
EndIf
If head\x > ScreenX-32
head\x = 0
ElseIf head\x < 0
head\x = ScreenX-32
ElseIf head\y > ScreenY-32
head\y = 0
ElseIf head\y < 0
head\y = ScreenY-32
EndIf
moved = 0
ResetList(body())
While NextElement(body())
If player = 2
If body()\x = head2\x And body()\y = head2\y
Gosub GameOver
EndIf
ResetList(body2())
While NextElement(body2())
If body()\x = body2()\x And body()\y = body2()\y
Gosub GameOver
EndIf
Wend
EndIf
If body()\x = head\x And body()\y = head\y
playerWin = 2
Gosub GameOver
EndIf
Wend
ResetList(body())
While NextElement(body())
body()\age + 1
If body()\age > head\length
DeleteElement(body())
EndIf
Wend
Return
;- MoveSnake 2
MoveSnake2:
playerWin = 2
AddElement(body2())
body2()\x = head2\x
body2()\y = head2\y
body2()\age = 1
If head2\direction = 1
head2\y - 32
ElseIf head2\direction = 2
head2\x + 32
ElseIf head2\direction = 3
head2\y + 32
ElseIf head2\direction = 4
head2\x - 32
EndIf
If head2\x > ScreenX-32
head2\x = 0
ElseIf head2\x < 0
head2\x = ScreenX-32
ElseIf head2\y > ScreenY-32
head2\y = 0
ElseIf head2\y < 0
head2\y = ScreenY-32
EndIf
moved2 = 0
ResetList(body2())
While NextElement(body2())
If body2()\x = head\x And body2()\y = head\y
Gosub GameOver
EndIf
If body2()\x = head2\x And body2()\y = head2\y
playerWin = 1
Gosub GameOver
EndIf
ResetList(body())
While NextElement(body())
If body2()\x = body()\x And body2()\y = body()\y
Gosub GameOver
EndIf
Wend
Wend
ResetList(body2())
While NextElement(body2())
body2()\age + 1
If body2()\age > head2\length
DeleteElement(body2())
EndIf
Wend
Return
;- Draw
Draw:
ClearScreen(RGB(0,0,0))
ResetList(food())
While NextElement(food())
DisplayTransparentSprite(food()\image, food()\x, food()\y)
food()\life - 1
If food()\life = 0
DeleteElement(food())
EndIf
Wend
ResetList(body())
While NextElement(body())
DisplayTransparentSprite(Color, body()\x, body()\y)
Wend
If player = 2
ResetList(body2())
While NextElement(body2())
DisplayTransparentSprite(Color2, body2()\x, body2()\y)
Wend
EndIf
Select head\direction
Case 1
DisplayTransparentSprite(Color+1, head\x, head\y)
Case 2
DisplayTransparentSprite(Color+2, head\x, head\y)
Case 3
DisplayTransparentSprite(Color+3, head\x, head\y)
Case 4
DisplayTransparentSprite(Color+4, head\x, head\y)
EndSelect
If player = 2
Select head2\direction
Case 1
DisplayTransparentSprite(Color2+1, head2\x, head2\y)
Case 2
DisplayTransparentSprite(Color2+2, head2\x, head2\y)
Case 3
DisplayTransparentSprite(Color2+3, head2\x, head2\y)
Case 4
DisplayTransparentSprite(Color2+4, head2\x, head2\y)
EndSelect
DrawTextXY("P2Score: "+Str(Score2),400,0)
EndIf
If Score > HiScore
HiScore = Score
EndIf
DrawTextXY("P1Score: "+Str(Score),200,0)
DrawTextXY("Hi Score: "+Str(HiScore),0,0)
FlipBuffers()
Return
;- GameOver
GameOver:
If player = 2
If Playerwin = 1
DrawTextXY("Player 1 Wins!",ScreenX/2-50,ScreenY/2-15)
DrawTextXY("Score: "+Str(Score),ScreenX/2-50,ScreenY/2)
ElseIf PlayerWin = 2
DrawTextXY("Player 2 Wins!",ScreenX/2-50,ScreenY/2-15)
DrawTextXY("Score: "+Str(Score2),ScreenX/2-50,ScreenY/2)
Else
DrawTextXY("Draw!",ScreenX/2-50,ScreenY/2-15)
DrawTextXY("Score: "+Str(Score),ScreenX/2-50,ScreenY/2)
EndIf
ElseIf player = 1
DrawTextXY("You Lose!",ScreenX/2-50,ScreenY/2-15)
DrawTextXY("Score: "+Str(Score),ScreenX/2-50,ScreenY/2)
EndIf
FlipBuffers()
Delay(2000)
If lvlsound > 49
StopSound(lvlsound)
EndIf
If player = 1
If Score > HiScore
DrawTextXY("A New HighScore!",ScreenX/2-50,ScreenY/2+20)
FlipBuffers()
Delay(1400)
HiScore = Score
EndIf
EndIf
If player = 2
NumberVersus + 1
EndIf
If OpenFile(0, "HS.snake")
WriteLong(0,HiScore-1234567890) ; a small encryption, nothing special tho
WriteLong(0,NumberVersus - 1234567890)
CloseFile(0)
EndIf
ResetList(body())
While NextElement(body())
DeleteElement(body())
Wend
If player = 2
ResetList(body2())
While NextElement(body2())
DeleteElement(body2())
Wend
EndIf
ResetList(food())
While NextElement(food())
DeleteElement(food())
Wend
Goto NewGame
;- Menu
Menu:
#MenuWindow = 1
#GADGET_FullScreen = 1
#GADGET_Players = 2
#GADGET_Launch = 4
#GADGET_Cancel = 5
#GADGET_Controller = 6
#GADGET_MaxFood = 7
#GADGET_ColorSelect = 13
#GADGET_Sound = 9
#GADGET_Image = 60
#GADGET_Speed = 12
#GADGET_Text1 = 20
If OpenWindow(#MenuWindow, 0, 0, 292, 320, "Snakes: by Kenny Cason", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)
CatchImage(0, ?head3) ; will be overwrote later
CatchImage(1, ?head23)
CatchImage(2, ?head33)
CatchImage(3, ?head43)
CatchImage(4, ?head53)
CatchImage(5, ?head63)
CatchImage(6, ?head73)
CatchImage(7, ?head83)
CatchImage(8, ?head93)
CatchImage(20,?misc1)
If ReadFile(0, "HS.snake")
HiScore = ReadLong(0)+1234567890
NumberVersus = ReadLong(0)+1234567890
If NumberVersus < 0
NumberVersus = 0
EndIf
If HiScore < 0
HiScore = 0
EndIf
CloseFile(0)
EndIf
Top = 6
ImageGadget(#GADGET_Image ,0 ,10,40,40,ImageID(0),#PB_Image_Border)
ImageGadget(#GADGET_Image+1,32 ,10,40,40,ImageID(1),#PB_Image_Border)
ImageGadget(#GADGET_Image+2,64 ,10,40,40,ImageID(2),#PB_Image_Border)
If HiScore > 300
ImageGadget(#GADGET_Image+3,96 ,10,40,40,ImageID(3),#PB_Image_Border)
Else
ImageGadget(#GADGET_Image+3,96 ,10,40,40,ImageID(20),#PB_Image_Border)
EndIf
If HiScore > 500
ImageGadget(#GADGET_Image+4,128,10,40,40,ImageID(4),#PB_Image_Border)
Else
ImageGadget(#GADGET_Image+4,128 ,10,40,40,ImageID(20),#PB_Image_Border)
EndIf
If HiScore > 700
ImageGadget(#GADGET_Image+5,160,10,40,40,ImageID(5),#PB_Image_Border)
Else
ImageGadget(#GADGET_Image+5,160 ,10,40,40,ImageID(20),#PB_Image_Border)
EndIf
If HiScore > 800
ImageGadget(#GADGET_Image+6,192,10,40,40,ImageID(6),#PB_Image_Border)
Else
ImageGadget(#GADGET_Image+6,192 ,10,40,40,ImageID(20),#PB_Image_Border)
EndIf
If HiScore > 900
ImageGadget(#GADGET_Image+7,224,10,40,40,ImageID(7),#PB_Image_Border)
Else
ImageGadget(#GADGET_Image+7,224 ,10,40,40,ImageID(20),#PB_Image_Border)
EndIf
If HiScore > 1000
ImageGadget(#GADGET_Image+8,256,10,40,40,ImageID(8),#PB_Image_Border)
Else
ImageGadget(#GADGET_Image+8,256 ,10,40,40,ImageID(20),#PB_Image_Border)
EndIf
Top+40
TextGadget(#GADGET_Text1+10,120,Top+2,90,20,"Hi Score")
TextGadget(#GADGET_Text1+11,120,Top+17,90,120,Str(HiScore))
TextGadget(#GADGET_Text1+12,200,Top+2,90,20,"Versus Matches")
TextGadget(#GADGET_Text1+13,200,Top+17,90,120,Str(NumberVersus))
CheckBoxGadget(#GADGET_FullScreen, 20, Top, 75, 20, "Full Screen") :Top + 20
CheckBoxGadget(#GADGET_Players, 20, Top, 75, 20, "2 Player") :Top + 20
TextGadget(#GADGET_Text1+14,20,Top,180,20,"Mult. Player Settings") : Top + 15
TextGadget(#GADGET_Text1,20,Top+2,90,20,"Player Speed")
TextGadget(#GADGET_Text1+1,105,Top+0,10,10,"-")
TextGadget(#GADGET_Text1+2,190,Top+0,10,10,"+")
TrackBarGadget(#GADGET_Speed, 110, Top, 80, 20, 0, 35) : Top+30
SetGadgetState(#GADGET_Speed, 10)
TextGadget(#GADGET_Text1+6,20,Top+2,90,20,"Max Food")
TextGadget(#GADGET_Text1+7,105,Top+0,10,10,"-")
TextGadget(#GADGET_Text1+8,190,Top+0,10,10,"+")
TrackBarGadget(#GADGET_MaxFood, 110, Top, 80, 20, 0, 50) : Top+35
SetGadgetState(#GADGET_MaxFood, 7)
TextGadget(#GADGET_Text1+3,10,Top,80,15,"Player 1")
ComboBoxGadget(#GADGET_ColorSelect,10,Top+15,80,20)
AddGadgetItem(#GADGET_ColorSelect,-1,"Green")
AddGadgetItem(#GADGET_ColorSelect,-1,"Yellow")
AddGadgetItem(#GADGET_ColorSelect,-1,"Orange")
If HiScore > 300
AddGadgetItem(#GADGET_ColorSelect,-1,"Blue")
EndIf
If HiScore > 500
AddGadgetItem(#GADGET_ColorSelect,-1,"Teal")
EndIf
If HiScore > 700
AddGadgetItem(#GADGET_ColorSelect,-1,"Red")
EndIf
If HiScore > 800
AddGadgetItem(#GADGET_ColorSelect,-1,"Purple")
EndIf
If HiScore > 900
AddGadgetItem(#GADGET_ColorSelect,-1,"Chost")
EndIf
If HiScore > 1000
AddGadgetItem(#GADGET_ColorSelect,-1,"Hippy")
EndIf
SetGadgetState(#GADGET_ColorSelect,0)
TextGadget(#GADGET_Text1+4,120,Top,80,15,"Player 2")
ComboBoxGadget(#GADGET_ColorSelect+1,120,Top+15,80,20) :Top + 45
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Green")
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Yellow")
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Orange")
If HiScore > 300
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Blue")
EndIf
If HiScore > 500
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Teal")
EndIf
If HiScore > 700
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Red")
EndIf
If HiScore > 800
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Purple")
EndIf
If HiScore > 900
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Ghost")
EndIf
If HiScore > 1000
AddGadgetItem(#GADGET_ColorSelect+1,-1,"Hippy")
EndIf
SetGadgetState(#GADGET_ColorSelect+1,1) ; set (beginning with 1) the 1st item as active one
TextGadget(#GADGET_Text1+5,10,Top,80,15,"Controller")
ComboBoxGadget(#GADGET_Controller,70,Top,80,20) :Top+40
AddGadgetItem(#GADGET_Controller,-1,"Disabled")
AddGadgetItem(#GADGET_Controller,-1,"Player 1")
AddGadgetItem(#GADGET_Controller,-1,"Player 2")
If joystick = 0
SetGadgetState(#GADGET_Controller,0)
Else
SetGadgetState(#GADGET_Controller,1)
EndIf
TextGadget(#GADGET_Text1+9,10,Top-15,80,60,"Music")
ComboBoxGadget(#GADGET_Sound,10,Top,100,20) :Top+30
AddGadgetItem(#GADGET_Sound,-1,"None")
AddGadgetItem(#GADGET_Sound,-1,"Music A")
AddGadgetItem(#GADGET_Sound,-1,"Music B")
AddGadgetItem(#GADGET_Sound,-1,"Music C")
AddGadgetItem(#GADGET_Sound,-1,"Music D")
SetGadgetState(#GADGET_Sound,0)
ButtonGadget(#GADGET_Launch, 6, Top, 95, 28, "Play", #PB_Button_Default)
ButtonGadget(#GADGET_Cancel, 111, Top, 95, 28, "Exit")
HideWindow(#MenuWindow,0)
lvlsoundold = GetGadgetState(#GADGET_Sound) + 49
lvlsoundnew = lvlsoundold
If lvlsoundnew > 49
PlaySound(lvlsoundnew,1)
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #GADGET_Sound
lvlsoundnew = GetGadgetState(#GADGET_Sound) + 49
If lvlsoundnew > 49
If lvlsoundnew <> lvlsoundold
If lvlsoundold > 49
StopSound(lvlsoundold)
EndIf
lvlsoundold = lvlsoundnew
PlaySound(lvlsoundnew,1)
EndIf
Else
If lvlsoundold > 49
StopSound(lvlsoundold)
EndIf
EndIf
Case #GADGET_Launch
Quitr = 1
Case #GADGET_Cancel
Quitr = 2
EndSelect
Case #PB_Event_CloseWindow
Quitr = 2
EndSelect
Until Quitr > 0
FullScreen = GetGadgetState(#GADGET_FullScreen)
StartSpeed = GetGadgetState(#GADGET_Speed)
Players = GetGadgetState(#GADGET_Players)
color = GetGadgetState(#GADGET_ColorSelect) * 5
color2 = GetGadgetState(#GADGET_ColorSelect+1) * 5
playerjoystick = GetGadgetState(#GADGET_Controller)
MaxFood = GetGadgetState(#GADGET_MaxFood)
If players = #False
Player = 1
Else
Player = 2
EndIf
CloseWindow(#MenuWindow)
EndIf
screenx = 640;1280; 800; 640
screeny = 480;1024; 600; 480
If player = 1
StartSpeed = 5
MaxFood = 5
EndIf
If Quitr = 2
End
Else
Return
EndIf
; ExecutableFormat=Windows
; UseIcon=C:\Documents and Settings\kenmister\Desktop\purebasic\Projects\snakes\sprites\head_3.ico
; Executable=C:\Documents and Settings\kenmister\Desktop\purebasic\Projects\snakes\Snakes.exe
; EOF
salutPCPixMusic a écrit :Bonjour,
Es qu'il existe une fonction qui permet de faire de la saisie de texte uniquement en mode graphique avec Input en Drawing 2D ?
Donc d'un équivalent de StringGadget
Une question que je me pose pour réaliser un jeu par exemple 100% graphique sans aucun gadget.
Mais aussi est surtout par curiosité.
Merci d'avance pour vos réponses.
Passez une bonne journée.
Code : Tout sélectionner
; basé sur l'exemple purebasic "KeyboardInkey()
Enumeration ; sprite
#sprite_PourEcrireTexte
#sprite_ZoneDeTexte
EndEnumeration
If InitSprite() = 0
MessageRequester("Erreur", "Impossible d'ouvrir l'écran & l'environnement nécessaire aux sprites !", 0)
End
EndIf
If InitKeyboard() = 0
MessageRequester("Erreur", "Impossible d'ouvrir le clavier, hou pinaise tu n'as pas de clavier ?? !", 0)
End
EndIf
; dimension fenêtre et screen
winW = 500
winH = 400
; couleur du tchat
col1 = 100
col2= 150
; un tableau pour afficher les lignes du tchat.
Dim zonetext$(0)
; POur le tchat (pas nécessaire ^^)
PoliceTchat = LoadFont(0, "Arial", 12)
If OpenWindow(0, 0, 0, winW, winH, "Zone de tchat", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, winW, winH)
; on crée le sprite pour écrire
CreateSprite(#sprite_PourEcrireTexte, winW, 20)
If StartDrawing(SpriteOutput(#sprite_PourEcrireTexte))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(Col1, col1, Col1))
StopDrawing()
EndIf
; on crée le sprite pour écrire
CreateSprite(#sprite_ZoneDeTexte, winW, 150)
If StartDrawing(SpriteOutput(#sprite_ZoneDeTexte))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(col2, col2, col2))
StopDrawing()
EndIf
Else
MessageRequester("Erreur", "Impossible d'ouvrir un écran dans la fenêtre!", 0)
End
EndIf
EndIf
direction = 2
Repeat
; Il est très important de traiter tous les évènements restants dans la file d'attente à chaque tour
;
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_LeftClick
; on vérifie si on a cliqué sur le sprite pour écrire
If WindowMouseY(0)>= winh-20
; on peut écrire sur le tchat
clicEcrire = 1
Else
clicEcrire = 0
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
; les actions qu'on fait sur le jeu
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
; on vérifie les actions ici
If clicEcrire = 1
; on vérifie le keyboard
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Return)
; on a appuyé sur entrée, on valide le texte
; ClicEcrire = 0
zonetext$(ligneTchat) = fulltext$ ; on ajoute un char de fin de chaine.
; on a ajouté une ligne à notre tableau de ligne de tchat, on incrémente.
ligneTchat +1
ReDim zonetext$(ligneTchat)
; on peut effacer le texte de zone de saisie.
fulltext$ = ""
; on met à jour le sprite pour le texte
If StartDrawing(SpriteOutput(#sprite_PourEcrireTexte))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(col1, col1, col1))
DrawingMode(#PB_2DDrawing_Transparent)
StopDrawing()
EndIf
; on met le text dans la zone à afficher
If StartDrawing(SpriteOutput(#sprite_ZoneDeTexte))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(Col2, col2, Col2))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(PoliceTchat)
; on dessine chaque ligne du tchat
For i = 0 To ArraySize(zonetext$())
; pour connaitre la taille de la police en pixel
If i = i
Htext = TextHeight(zonetext$(i))
EndIf
; ensuite, on dessine
DrawText(0,i*Htext,zonetext$(i))
Next i
StopDrawing()
EndIf
Else
If KeyboardReleased(#PB_Key_Back)
FullText$ = Left(FullText$, Len(FullText$)-1)
Else
char$ = KeyboardInkey()
; on veirife qu'on a appuyé
If FindString("1234567890 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzéèçàù.,;:/?!&é(-_)=+#{[|`\^@]}$%", char$)
FullText$ + char$
EndIf
EndIf
; on met à jour le sprite pour le texte
If StartDrawing(SpriteOutput(#sprite_PourEcrireTexte))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(col1, col1, col1))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(0,0,FullText$)
StopDrawing()
EndIf
EndIf
EndIf
EndIf
; on affiche
DisplaySprite(#sprite_ZoneDeTexte, 0, winh-20-SpriteHeight(#sprite_ZoneDeTexte))
DisplaySprite(#sprite_PourEcrireTexte, 0, winh-20)
Delay(1)
ForEver
Bonjour TazNormand,TazNormand a écrit :@PCPixMusic : J'ai fusionné tes messages ; si possible postes un message avec plusieurs questions au lieu de mettre x messages, surtout si ça concerne un sujet unique.
Autre chose, le UP, c'est bien, mais faut le faire sur un de tes messages, et comme tu le dis si bien : "Passez un bon Week-End" !
On est tous en week-end, voire en vacances pour plusieurs d'entre nous, tu comprendras que les réponses ne vont pas tomber comme ça en 5 minutes.
"Patience est mère de toutes les vertus" dit le dicton
Bonjour grendizer,grendizer a écrit :bonjour PCPixMusic
c'est pour un HighScore d'un jeu?
sinon regarde ça : https://github.com/kennycason/snakes
c'est une version 3.94 de PB mais le gars a codé un setting pour son jeu snake .
si cela peux t'aider .
Bon dimanche
Bonjour grendizer,grendizer a écrit :bonjour PCPixMusic
c'est pour un HighScore d'un jeu?
sinon regarde ça : https://github.com/kennycason/snakes
c'est une version 3.94 de PB mais le gars a codé un setting pour son jeu snake .
si cela peux t'aider .
Bon dimanche
Code : Tout sélectionner
Enumeration
#Fenetre_Saya
#Label_igne_01
#Label_igne_02
#Label_igne_03
#Label_igne_04
#Label_igne_05
#Label_igne_06
#Label_igne_07
#Label_igne_08
#Label_igne_09
#Label_igne_10
#Label_igne_11
#Label_igne_12
#Label_igne_13
#Label_igne_14
#Label_igne_15
#Label_igne_16
#Label_igne_17
#Label_igne_18
#Label_igne_19
#Label_igne_20
#Label_igne_21
#Label_igne_22
#Label_igne_23
#Label_igne_24
#Label_igne_25
#Label_Colonne_01
#Label_Colonne_02
#Label_Colonne_03
#Label_Colonne_04
#Label_Colonne_05
#Label_Colonne_06
#Label_Colonne_07
#Label_Colonne_08
#Label_Colonne_09
#Label_Colonne_10
#Select_All
#ScrollBar
#Menu_SQlite3_Nouvelle_BDD
#Menu_SQlite3_Ouvrir_BDD
#Menu_SQlite3_Nouvelle_Fiche_BDD
#Menu_SQlite3_MAJ_BDD
#Menu_SQlite3_Quitter
#Menu_Edition_Couper
#Menu_Edition_Copier
#Menu_Edition_Coller
#Menu_Edition_Import_Blob
#Menu_Rechercher
#Menu_Rechercher_Suivant
#Menu_Aide
#Menu_A_Propos
#ID_Bouton_close_a_propos
;==========================================
#Image_Nouvelle
#Image_Open
#Image_Nouvelle_Fiche
#Image_MAJ_BDD
#Image_Quitter
#Image_Couper
#Image_Copier
#Image_Coller
#Image_Import_Blob
#Image_Rechercher
#Image_Rechercher_Suivant
#Image_Aide
#Image_A_Propos
;==========================================
#Fenetre_a_propos
#TextAPropos1
#TextAPropos2
#TextAPropos3
#TextAPropos4
#Select_Key_Cellule
#Font_Saya
#Entree_Cellule
EndEnumeration
Global.s Label_Colonne_01
Global.s Label_Colonne_02
Global.s Label_Colonne_03
Global.s Label_Colonne_04
Global.s Label_Colonne_05
Global.s Label_Colonne_06
Global.s Label_Colonne_07
Global.s Label_Colonne_08
Global.s Label_Colonne_09
Global.s Label_Colonne_10
;=========================== Largeur des Colonne ===========================
Global.i Largeur_Colonne_01 = 180
Global.i Largeur_Colonne_02 = 180
Global.i Largeur_Colonne_03 = 180
Global.i Largeur_Colonne_04 = 180
Global.i Largeur_Colonne_05 = 180
Global.i Largeur_Colonne_06 = 180
Global.i Largeur_Colonne_07 = 180
Global.i Largeur_Colonne_08 = 180
Global.i Largeur_Colonne_09 = 180
Global.i Largeur_Colonne_10 = 180
;===========================================================================
Global.i ligne_01 = 1
Global.i ligne_02 = 2
Global.i ligne_03 = 3
Global.i ligne_04 = 4
Global.i ligne_05 = 5
Global.i ligne_06 = 6
Global.i ligne_07 = 7
Global.i ligne_08 = 8
Global.i ligne_09 = 9
Global.i ligne_10 = 10
Global.i ligne_11 = 11
Global.i ligne_12 = 12
Global.i ligne_13 = 13
Global.i ligne_14 = 14
Global.i ligne_15 = 15
Global.i ligne_16 = 16
Global.i ligne_17 = 17
Global.i ligne_18 = 18
Global.i ligne_19 = 19
Global.i ligne_20 = 20
Global.i ligne_21 = 21
Global.i ligne_22 = 22
Global.i ligne_23 = 23
Global.i ligne_24 = 24
Global.i ligne_25 = 25
Global.i glEvent, glGadget, glType, Quitter = 0
Global Separateur.s
Global IndexSeparateur.i
Global.i SourisX,SourisY,SourisX_Save,SourisY_Save
;Global Separateur.s = "\" ;Windows
Global Separateur.s = "/" ;Linux
UseOGGSoundDecoder() ; Utilisation des fichiers Ogg
UseFLACSoundDecoder() ; Utilisation des fichiers Flac
UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTIFFImageDecoder()
UseTGAImageDecoder()
UseGIFImageDecoder()
InitMouse()
Procedure PosClic(MouseX.i,MouseY.i, x0.i,y0.i,x1.i,y1.i)
If MouseX >= x0 And MouseX <= x1 And MouseY >= y0 And MouseY <= y1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure PosClicFac(MouseX.i,MouseY.i, x0.i,y0.i,x1.i,y1.i)
If MouseX >= x0 And MouseX <= x0+x1 And MouseY >= y0 And MouseY <= y0+y1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure PosClicCercle(MouseX.i,MouseY.i,x.i,y.i,Radius.i)
If MouseX >= x And MouseX <= x*Radius And MouseX >= x And MouseX <= x/Radius And
MouseY >= y And MouseY <= y*Radius And MouseY >= y And MouseY <= y/Radius
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure PixCadreColor(X1.i,Y1.i,X2.i,Y2.i,Color.i)
LineXY(X1,Y1,X2,Y1,Color)
LineXY(X1,Y1,X1,Y2,Color)
LineXY(X2,Y1,X2,Y2,Color)
LineXY(X1,Y2,X2,Y2,Color)
EndProcedure
Procedure CadreCel(X1.i,Y1.i,FacX.i,FacY.i,Color.i)
LineXY(X1,Y1,X1+FacX,Y1,Color) ;Ligne Horizontale Haut 1
LineXY(X1,Y1,X1,Y1+FacY,Color) ;Ligne Verticale Gauche 1
LineXY(X1,Y1+1,X1+FacX,Y1+1,Color) ;Ligne Horizontale Haut 2
LineXY(X1+1,Y1,X1+1,Y1+FacY,Color) ;Ligne Verticale Gauche 2
LineXY(X1+FacX-1,Y1,X1+FacX-1,Y1+FacY,Color) ;Ligne Verticale Droite 1
LineXY(X1,Y1+FacY-1,X1+FacX,Y1+FacY-1,Color) ;Ligne Horizontale Bas 1
LineXY(X1+FacX,Y1,X1+FacX,Y1+FacY,Color) ;Ligne Verticale Droite 2
LineXY(X1,Y1+FacY,X1+FacX,Y1+FacY,Color) ;Ligne Horizontale Bas 1
EndProcedure
Procedure TextCadre(X1.i,Y1.i,Texte.s,Color.i)
Protected X2.i,Y2.i
X1 = X1 - 20
Y1 = Y1 + 17
X2 = X1+100
Y2 = Y1+25
;LineXY(X1,Y1,X2,Y1,#Black)
;LineXY(X1,Y1,X1,Y2,#Black)
;LineXY(X2,Y1,X2,Y2,#Black)
;LineXY(X1,Y2,X2,Y2,#Black)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(X1-40,Y2-45,Texte,Color,#PB_2DDrawing_Transparent)
EndProcedure
;============================================================================================================================================================
Procedure Labels_Ligne_Grid(X.i,
Y.i,
Largeur_Colonne_01.i,
Largeur_Colonne_02.i,
Largeur_Colonne_03.i,
Largeur_Colonne_04.i,
Largeur_Colonne_05.i,
Largeur_Colonne_06.i,
Largeur_Colonne_07.i,
Largeur_Colonne_08.i,
Largeur_Colonne_09.i,
Largeur_Colonne_10.i,
Hauteur_Cellule.i,
Titre_Colone_01.s,
Titre_Colone_02.s,
Titre_Colone_03.s,
Titre_Colone_04.s,
Titre_Colone_05.s,
Titre_Colone_06.s,
Titre_Colone_07.s,
Titre_Colone_08.s,
Titre_Colone_09.s,
Titre_Colone_10.s)
ButtonGadget(#Label_Colonne_01,X,l+Y, Largeur_Colonne_01,Hauteur_Cellule,Titre_Colone_01,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_02,X+Largeur_Colonne_01,l+Y_Cellule,Largeur_Colonne_02,Hauteur_Cellule,Titre_Colone_02,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_03,X+Largeur_Colonne_01+Largeur_Colonne_02,l+Y,Largeur_Colonne_03,Hauteur_Cellule,Titre_Colone_03,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_04,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03,l+Y,Largeur_Colonne_04,Hauteur_Cellule,Titre_Colone_04,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_05,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03+Largeur_Colonne_04,l+Y_Cellule,Largeur_Colonne_05,Hauteur_Cellule,Titre_Colone_05,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_06,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03+Largeur_Colonne_04+Largeur_Colonne_05,l+Y_Cellule,Largeur_Colonne_06,Hauteur_Cellule,Titre_Colone_06,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_07,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03+Largeur_Colonne_04+Largeur_Colonne_05+Largeur_Colonne_06,l+Y_Cellule,Largeur_Colonne_07,Hauteur_Cellule,Titre_Colone_07,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_08,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03+Largeur_Colonne_04+Largeur_Colonne_05+Largeur_Colonne_06+Largeur_Colonne_07,l+Y,Largeur_Colonne_08,Hauteur_Cellule,Titre_Colone_08,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_09,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03+Largeur_Colonne_04+Largeur_Colonne_05+Largeur_Colonne_06+Largeur_Colonne_07+Largeur_Colonne_08,l+Y,Largeur_Colonne_09,Hauteur_Cellule,Titre_Colone_09,#PB_Button_Toggle)
ButtonGadget(#Label_Colonne_10,X+Largeur_Colonne_01+Largeur_Colonne_02+Largeur_Colonne_03+Largeur_Colonne_04+Largeur_Colonne_05+Largeur_Colonne_06+Largeur_Colonne_07+Largeur_Colonne_08+Largeur_Colonne_09,l+Y,Largeur_Colonne_10,Hauteur_Cellule,Titre_Colone_10,#PB_Button_Toggle)
EndProcedure
Procedure Affiche_Numeros(index.i)
Protected.i num
index = index -1
SetGadgetText(#Label_igne_01,Str(Index+1))
SetGadgetText(#Label_igne_02,Str(Index+2))
SetGadgetText(#Label_igne_03,Str(Index+3))
SetGadgetText(#Label_igne_04,Str(Index+4))
SetGadgetText(#Label_igne_05,Str(Index+5))
SetGadgetText(#Label_igne_06,Str(Index+6))
SetGadgetText(#Label_igne_07,Str(Index+7))
SetGadgetText(#Label_igne_08,Str(Index+8))
SetGadgetText(#Label_igne_09,Str(Index+9))
SetGadgetText(#Label_igne_10,Str(Index+10))
SetGadgetText(#Label_igne_11,Str(Index+11))
SetGadgetText(#Label_igne_12,Str(Index+12))
SetGadgetText(#Label_igne_13,Str(Index+13))
SetGadgetText(#Label_igne_14,Str(Index+14))
SetGadgetText(#Label_igne_15,Str(Index+15))
SetGadgetText(#Label_igne_16,Str(Index+16))
SetGadgetText(#Label_igne_17,Str(Index+17))
SetGadgetText(#Label_igne_18,Str(Index+18))
SetGadgetText(#Label_igne_19,Str(Index+19))
SetGadgetText(#Label_igne_20,Str(Index+20))
SetGadgetText(#Label_igne_21,Str(Index+21))
SetGadgetText(#Label_igne_22,Str(Index+22))
SetGadgetText(#Label_igne_23,Str(Index+23))
SetGadgetText(#Label_igne_24,Str(Index+24))
SetGadgetText(#Label_igne_25,Str(Index+25))
EndProcedure
Procedure Grid()
Protected.i Largeur_Label = 60
Protected.i Hauteur_Cellule = 20
Protected.i j = 0
Protected.i X = 0
Protected.i Y = 0
Protected.i Largeur_Colonne_01 = 180
Protected.i Largeur_Colonne_02 = 180
Protected.i Largeur_Colonne_03 = 180
Protected.i Largeur_Colonne_04 = 180
Protected.i Largeur_Colonne_05 = 180
Protected.i Largeur_Colonne_06 = 180
Protected.i Largeur_Colonne_07 = 180
Protected.i Largeur_Colonne_08 = 180
Protected.i Largeur_Colonne_09 = 180
Protected.i Largeur_Colonne_10 = 180
ButtonGadget(#Select_All,0,0,60,50,"",#PB_Button_Toggle)
Labels_Ligne_Grid(X+Largeur_Label,
Y,
Largeur_Colonne_01,
Largeur_Colonne_02,
Largeur_Colonne_03,
Largeur_Colonne_04,
Largeur_Colonne_05,
Largeur_Colonne_06,
Largeur_Colonne_07,
Largeur_Colonne_08,
Largeur_Colonne_09,
Largeur_Colonne_10,
Hauteur_Cellule,
"Prenom",
"Nom",
"Enteprise",
"Adresse",
"Code postal",
"Ville",
"Pays",
"Téléphone",
"E-Mail",
"Site")
;=========== Labels de la colonne 0 ===========
ButtonGadget(#Label_igne_01, X,Y+33 ,Largeur_Label,20,Str(ligne_01),#PB_Button_Toggle)
ButtonGadget(#Label_igne_02, X,Y+66 ,Largeur_Label,20,Str(ligne_02),#PB_Button_Toggle)
ButtonGadget(#Label_igne_03, X,Y+99 ,Largeur_Label,20,Str(ligne_03),#PB_Button_Toggle)
ButtonGadget(#Label_igne_04, X,Y+132,Largeur_Label,20,Str(ligne_04),#PB_Button_Toggle)
ButtonGadget(#Label_igne_05, X,Y+165,Largeur_Label,20,Str(ligne_05),#PB_Button_Toggle)
ButtonGadget(#Label_igne_06, X,Y+198,Largeur_Label,20,Str(ligne_06),#PB_Button_Toggle)
ButtonGadget(#Label_igne_07, X,Y+231,Largeur_Label,20,Str(ligne_07),#PB_Button_Toggle)
ButtonGadget(#Label_igne_08, X,Y+264,Largeur_Label,20,Str(ligne_08),#PB_Button_Toggle)
ButtonGadget(#Label_igne_09, X,Y+297,Largeur_Label,20,Str(ligne_09),#PB_Button_Toggle)
ButtonGadget(#Label_igne_10, X,Y+330,Largeur_Label,20,Str(ligne_10),#PB_Button_Toggle)
ButtonGadget(#Label_igne_11, X,Y+363,Largeur_Label,20,Str(ligne_11),#PB_Button_Toggle)
ButtonGadget(#Label_igne_12, X,Y+396,Largeur_Label,20,Str(ligne_12),#PB_Button_Toggle)
ButtonGadget(#Label_igne_13, X,Y+429,Largeur_Label,20,Str(ligne_13),#PB_Button_Toggle)
ButtonGadget(#Label_igne_14, X,Y+462,Largeur_Label,20,Str(ligne_14),#PB_Button_Toggle)
ButtonGadget(#Label_igne_15, X,Y+495,Largeur_Label,20,Str(ligne_15),#PB_Button_Toggle)
ButtonGadget(#Label_igne_16, X,Y+528,Largeur_Label,20,Str(ligne_16),#PB_Button_Toggle)
ButtonGadget(#Label_igne_17, X,Y+561,Largeur_Label,20,Str(ligne_17),#PB_Button_Toggle)
ButtonGadget(#Label_igne_18, X,Y+594,Largeur_Label,20,Str(ligne_18),#PB_Button_Toggle)
ButtonGadget(#Label_igne_19, X,Y+627,Largeur_Label,20,Str(ligne_19),#PB_Button_Toggle)
ButtonGadget(#Label_igne_20, X,Y+660,Largeur_Label,20,Str(ligne_20),#PB_Button_Toggle)
ButtonGadget(#Label_igne_21, X,Y+693,Largeur_Label,20,Str(ligne_21),#PB_Button_Toggle)
ButtonGadget(#Label_igne_22, X,Y+726,Largeur_Label,20,Str(ligne_22),#PB_Button_Toggle)
ButtonGadget(#Label_igne_23, X,Y+759,Largeur_Label,20,Str(ligne_23),#PB_Button_Toggle)
ButtonGadget(#Label_igne_24, X,Y+792,Largeur_Label,20,Str(ligne_24),#PB_Button_Toggle)
ButtonGadget(#Label_igne_25, X,Y+825,Largeur_Label,20,Str(ligne_25),#PB_Button_Toggle)
;=========== Nombres de Lignes
If StartDrawing(CanvasOutput(#Fenetre_Saya))
BackColor(RGB(255,255,255))
FrontColor(RGB(0, 0, 0))
Box(0,0,1867,900,RGB(255,255,255))
For x = 60 To 1880 Step 180
LineXY(x,0,x,860)
Next
For y = 33 To 900 Step 33
LineXY(60,y,1860,y)
Next
StopDrawing()
EndIf
EndProcedure
Procedure Menu()
If LoadImage(#Image_Nouvelle,"Icons/Flou.png")
ResizeImage(#Image_Nouvelle,16,16)
EndIf
If LoadImage(#Image_Open,"Icons/Open.png")
ResizeImage(#Image_Open,16,16)
EndIf
If LoadImage(#Image_Nouvelle_Fiche,"Icons/Flou.png")
ResizeImage(#Image_Nouvelle_Fiche,16,16)
EndIf
If LoadImage(#Image_MAJ_BDD,"Icons/Pal.png")
ResizeImage(#Image_MAJ_BDD,16,16)
EndIf
If LoadImage(#Image_Quitter,"Icons/Flou_Gris.png")
ResizeImage(#Image_Quitter,16,16)
EndIf
;=============================================================================================
If LoadImage(#Image_Couper,"Icons/Open_Blob.png")
ResizeImage(#Image_Couper,16,16)
EndIf
If LoadImage(#Image_Copier,"Icons/Open_Blob.png")
ResizeImage(#Image_Copier,16,16)
EndIf
If LoadImage(#Image_Coller,"Icons/Open_Blob.png")
ResizeImage(#Image_Coller,16,16)
EndIf
If LoadImage(#Image_Import_Blob,"Icons/Open_Blob.png")
ResizeImage(#Image_Import_Blob,16,16)
EndIf
;=============================================================================================
If LoadImage(#Image_Rechercher,"Icons/Open_Blob.png")
ResizeImage(#Image_Rechercher,16,16)
EndIf
If LoadImage(#Image_Rechercher_Suivant,"Icons/Open_Blob.png")
ResizeImage(#Image_Rechercher_Suivant,16,16)
EndIf
;=============================================================================================
If LoadImage(#Image_Aide,"Icons/Open_Blob.png")
ResizeImage(#Image_Aide,16,16)
EndIf
If LoadImage(#Image_A_Propos,"Icons/A_Propos.png")
ResizeImage(#Image_A_Propos,16,16)
EndIf
;=============================================================================================
If CreateImageMenu(#Fenetre_Saya,WindowID(#Fenetre_Saya), #PB_Menu_ModernLook)
MenuTitle("SQlite3")
MenuItem(#Menu_SQlite3_Nouvelle_BDD,"Nouvelle BDD"+Chr(9)+"Ctrl+N",ImageID(#Image_Nouvelle))
MenuItem(#Menu_SQlite3_Ouvrir_BDD,"Ouvrir"+Chr(9)+"Ctrl+O",ImageID(#Image_Open))
MenuItem(#Menu_SQlite3_Nouvelle_Fiche_BDD,"Nouvelle fiche BDD"+Chr(9)+"Ctrl+F",ImageID(#Image_Nouvelle_Fiche))
MenuItem(#Menu_SQlite3_MAJ_BDD,"Mise a jour d'une BDD"+Chr(9)+"Ctrl+M",ImageID(#Image_MAJ_BDD))
MenuBar() ;la barre de séparation sera insérée ici
MenuItem(#Menu_SQlite3_Quitter,"Quitter Saya"+Chr(9)+"Ctrl+Q",ImageID(#Image_Quitter))
;===============================================================================================
MenuTitle("Edition")
MenuItem(#Menu_Edition_Couper,"Couper"+Chr(9)+"Ctrl+X",ImageID(#Image_Couper))
MenuItem(#Menu_Edition_Copier,"Copier"+Chr(9)+"Ctrl+C",ImageID(#Image_Copier))
MenuItem(#Menu_Edition_Coller,"Coller"+Chr(9)+"Ctrl+V",ImageID(#Image_Coller))
MenuBar() ;la barre de séparation sera insérée ici
MenuItem(#Menu_Edition_Import_Blob,"Importer une image blob ..."+Chr(9)+"Ctrl+I",ImageID(#Image_Import_Blob))
;===============================================================================================
MenuTitle("Rechercher")
MenuItem(#Menu_Rechercher,"Couper"+Chr(9)+"Ctrl+R",ImageID(#Image_Rechercher))
MenuItem(#Menu_Rechercher_Suivant,"Copier"+Chr(9)+"F3",ImageID(#Image_Rechercher_Suivant))
;===============================================================================================
MenuTitle("Aide")
MenuItem(#Menu_Aide,"Ade"+Chr(9)+"F1",ImageID(#Image_Aide))
MenuItem(#Menu_A_Propos,"A Propos"+Chr(9)+"Ctrl+A",ImageID(#Image_A_Propos))
;===============================================================================================
EndIf
EndProcedure
;==============================================================================================================
Procedure Fenetre_Saya()
Protected.i ajuste_bar_linux = 60
Protected.i taille_linux = 47
If OpenWindow(#Fenetre_Saya, 0,0,1874,910, "Notysoft Saya - Gestion de Contacts - 2016 - 2021", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
CanvasGadget(#Fenetre_Saya,0,0,1874,859, #PB_Canvas_Container)
Menu()
Grid()
ScrollBarGadget(#ScrollBar, 1861, 1, 12, 860 ,0, 1450, 50, #PB_ScrollBar_Vertical)
AddKeyboardShortcut(#Fenetre_Saya,#PB_Shortcut_Return,#Select_Key_Cellule)
;StringGadget(#Entree_Cellule,62,35,177,30,"",#PB_String_BorderLess)
;Debug GetGadgetState(#ScrollBar)
EndIf
EndProcedure
Procedure Main()
Repeat
If StartDrawing(CanvasOutput(#Fenetre_Saya))
BackColor(RGB(255,255,255))
FrontColor(RGB(0, 0, 0))
If GetGadgetState(#ScrollBar) < 35
Affiche_Numeros(1)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 70
Affiche_Numeros(26)
EndIf
If GetGadgetState(#ScrollBar) > 105
Affiche_Numeros(51)
EndIf
If GetGadgetState(#ScrollBar) > 140
Affiche_Numeros(76)
EndIf
If GetGadgetState(#ScrollBar) > 175
Affiche_Numeros(101)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 210
Affiche_Numeros(126)
EndIf
If GetGadgetState(#ScrollBar) > 245
Affiche_Numeros(151)
EndIf
If GetGadgetState(#ScrollBar) > 280
Affiche_Numeros(176)
EndIf
If GetGadgetState(#ScrollBar) > 315
Affiche_Numeros(201)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 350
Affiche_Numeros(226)
EndIf
If GetGadgetState(#ScrollBar) > 385
Affiche_Numeros(251)
EndIf
If GetGadgetState(#ScrollBar) > 420
Affiche_Numeros(276)
EndIf
If GetGadgetState(#ScrollBar) > 455
Affiche_Numeros(301)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 490
Affiche_Numeros(326)
EndIf
If GetGadgetState(#ScrollBar) > 525
Affiche_Numeros(351)
EndIf
If GetGadgetState(#ScrollBar) > 560
Affiche_Numeros(376)
EndIf
If GetGadgetState(#ScrollBar) > 595
Affiche_Numeros(401)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 630
Affiche_Numeros(426)
EndIf
If GetGadgetState(#ScrollBar) > 665
Affiche_Numeros(451)
EndIf
If GetGadgetState(#ScrollBar) > 700
Affiche_Numeros(476)
EndIf
If GetGadgetState(#ScrollBar) > 735
Affiche_Numeros(501)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 770
Affiche_Numeros(526)
EndIf
If GetGadgetState(#ScrollBar) > 805
Affiche_Numeros(551)
EndIf
If GetGadgetState(#ScrollBar) > 840
Affiche_Numeros(576)
EndIf
If GetGadgetState(#ScrollBar) > 875
Affiche_Numeros(601)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 910
Affiche_Numeros(626)
EndIf
If GetGadgetState(#ScrollBar) > 945
Affiche_Numeros(651)
EndIf
If GetGadgetState(#ScrollBar) > 980
Affiche_Numeros(676)
EndIf
If GetGadgetState(#ScrollBar) > 1015
Affiche_Numeros(601)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 1050
Affiche_Numeros(726)
EndIf
If GetGadgetState(#ScrollBar) > 1085
Affiche_Numeros(751)
EndIf
If GetGadgetState(#ScrollBar) > 1120
Affiche_Numeros(776)
EndIf
If GetGadgetState(#ScrollBar) > 1155
Affiche_Numeros(801)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 1190
Affiche_Numeros(826)
EndIf
If GetGadgetState(#ScrollBar) > 1225
Affiche_Numeros(851)
EndIf
If GetGadgetState(#ScrollBar) > 1260
Affiche_Numeros(876)
EndIf
;========================================================
If GetGadgetState(#ScrollBar) > 1295
Affiche_Numeros(901)
EndIf
If GetGadgetState(#ScrollBar) > 1330
Affiche_Numeros(926)
EndIf
If GetGadgetState(#ScrollBar) > 1365
Affiche_Numeros(951)
EndIf
If GetGadgetState(#ScrollBar) > 1400
Affiche_Numeros(976)
EndIf
;========================================================
StopDrawing()
EndIf
Select WaitWindowEvent()
;Case #PB_EventType_MouseWheel
; MessageRequester("",Str(#PB_Canvas_WheelDelta))
Case #PB_Event_Gadget
Select EventGadget()
Case #Fenetre_Saya
SourisX = GetGadgetAttribute(#Fenetre_Saya, #PB_Canvas_MouseX)
SourisY = GetGadgetAttribute(#Fenetre_Saya, #PB_Canvas_MouseY)
EndSelect
Select EventType()
Case #PB_EventType_MouseMove
LoadFont(#Font_Saya, "Arial", 14)
If StartDrawing(CanvasOutput(#Fenetre_Saya))
DrawingFont(FontID(#Font_Saya))
BackColor(RGB(255,255,255))
FrontColor(RGB(0, 0, 0))
SourisX_Save = SourisX
SourisY_Save = SourisY
DrawText(70,40,""+SourisX_Save+" "+SourisY_Save)
StopDrawing()
EndIf
Case #PB_EventType_LeftButtonDown
For j = 0 To 1867 Step 180
For i = 0 To 800 Step 33
If PosClicFac(SourisX,SourisY,60+j,34+i,180,33)
If StartDrawing(CanvasOutput(#Fenetre_Saya))
BackColor(RGB(255,255,255))
FrontColor(RGB(0, 0, 0))
Box(0,0,1867,900,RGB(255,255,255))
For x = 60 To 1880 Step 180
LineXY(x,0,x,860)
Next
For y = 33 To 900 Step 33
LineXY(60,y,1860,y)
Next
CadreCel(60+j,34+i,179,31,#Black)
StopDrawing()
EndIf
EndIf
Next
Next
Case #PB_EventType_RightButtonDown
If PosClicFac(SourisX,SourisY,70,30,1874,910)
If StartDrawing(CanvasOutput(#Fenetre_Saya))
BackColor(RGB(255,255,255))
FrontColor(RGB(0, 0, 0))
Box(0,0,1867,900,RGB(255,255,255))
For x = 60 To 1880 Step 180
LineXY(x,0,x,860)
Next
For y = 33 To 900 Step 33
LineXY(60,y,1860,y)
Next
StopDrawing()
EndIf
EndIf
EndSelect
Case #PB_Event_Menu ; Un élément du menu a été sélectionné
Select EventMenu() ; On recupère le numéro de cet élement...
;Case #Menu_SQlite3_Ouvrir_BDD = 1002
;Case #Menu_SQlite3_Nouvelle_Fiche_BDD = 1003
;Case #Menu_SQlite3_MAJ_BDD = 1004
Case #Menu_SQlite3_Quitter : End
Case #Menu_A_Propos : MessageRequester("A Propos",#CRLF$+"Notysoft Saya - 2019 - 2021 - v1.00"+#CRLF$+"Gestionnaire de contacts SQLite3.")
Case #Select_Key_Cellule
StringGadget(#Entree_Cellule,62,35,177,30,"",#PB_String_BorderLess)
;CadreCel(60+j,34+i,179,31,#Black)
;MessageRequester("Position de la souris","Je suis la touche entrée en ("+SourisX_Save+":"+SourisY_Save+")")
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Fenetre_Saya : End
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndProcedure
Fenetre_Saya()
Main()
Code : Tout sélectionner
SetGadgetText(#Label_igne_01,Str(Index+1))
SetGadgetText(#Label_igne_02,Str(Index+2))
SetGadgetText(#Label_igne_03,Str(Index+3))
SetGadgetText(#Label_igne_04,Str(Index+4))
SetGadgetText(#Label_igne_05,Str(Index+5))
SetGadgetText(#Label_igne_06,Str(Index+6))
SetGadgetText(#Label_igne_07,Str(Index+7))
SetGadgetText(#Label_igne_08,Str(Index+8))
SetGadgetText(#Label_igne_09,Str(Index+9))
SetGadgetText(#Label_igne_10,Str(Index+10))
SetGadgetText(#Label_igne_11,Str(Index+11))
SetGadgetText(#Label_igne_12,Str(Index+12))
SetGadgetText(#Label_igne_13,Str(Index+13))
SetGadgetText(#Label_igne_14,Str(Index+14))
SetGadgetText(#Label_igne_15,Str(Index+15))
SetGadgetText(#Label_igne_16,Str(Index+16))
SetGadgetText(#Label_igne_17,Str(Index+17))
SetGadgetText(#Label_igne_18,Str(Index+18))
SetGadgetText(#Label_igne_19,Str(Index+19))
SetGadgetText(#Label_igne_20,Str(Index+20))
SetGadgetText(#Label_igne_21,Str(Index+21))
SetGadgetText(#Label_igne_22,Str(Index+22))
SetGadgetText(#Label_igne_23,Str(Index+23))
SetGadgetText(#Label_igne_24,Str(Index+24))
SetGadgetText(#Label_igne_25,Str(Index+25))
Code : Tout sélectionner
For i= 1 to 25
SetGadgetText(#Label_igne_01+i,Str(Index+i))
Next i
Code : Tout sélectionner
Global.s Label_Colonne_01
Global.s Label_Colonne_02
Global.s Label_Colonne_03
Global.s Label_Colonne_04
Global.s Label_Colonne_05
Global.s Label_Colonne_06
Global.s Label_Colonne_07
Global.s Label_Colonne_08
Global.s Label_Colonne_09
Global.s Label_Colonne_10
;=========================== Largeur des Colonne ===========================
Global.i Largeur_Colonne_01 = 180
Global.i Largeur_Colonne_02 = 180
Global.i Largeur_Colonne_03 = 180
Global.i Largeur_Colonne_04 = 180
Global.i Largeur_Colonne_05 = 180
Global.i Largeur_Colonne_06 = 180
Global.i Largeur_Colonne_07 = 180
Global.i Largeur_Colonne_08 = 180
Global.i Largeur_Colonne_09 = 180
Global.i Largeur_Colonne_10 = 180
Code : Tout sélectionner
Global.s dim Label_Colonne(10)
For i=1 to 10
Label_Colonne(i) = 180
Next
Code : Tout sélectionner
Global.i ligne_01 = 1
Global.i ligne_02 = 2
Global.i ligne_03 = 3
Global.i ligne_04 = 4
Global.i ligne_05 = 5
Global.i ligne_06 = 6
Global.i ligne_07 = 7
Global.i ligne_08 = 8
Global.i ligne_09 = 9
Global.i ligne_10 = 10
Global.i ligne_11 = 11
Global.i ligne_12 = 12
Global.i ligne_13 = 13
Global.i ligne_14 = 14
Global.i ligne_15 = 15
Global.i ligne_16 = 16
Global.i ligne_17 = 17
Global.i ligne_18 = 18
Global.i ligne_19 = 19
Global.i ligne_20 = 20
Global.i ligne_21 = 21
Global.i ligne_22 = 22
Global.i ligne_23 = 23
Global.i ligne_24 = 24
Global.i ligne_25 = 25
Code : Tout sélectionner
Global.i dim ligne_(25)
For i=1 to 25
ligne_(i) = i
Next
Merci, pour faire un screen du programme exécuté ?kernadec a écrit :salut PCPixMusic
Envoye tes images sur ce site
https://www.zupimages.net/
ensuite il faut utiliser 3ème lien et l'image s'affichera dans ton message
cordialement