Tout fonctionne sauf si je scroll. Quand je Leftclick au coup la map scrollé, la tiles est égaré. (Vous aller voir si vous le tester parce que c'est dur a dire

Voici le code:
Les Images #R_Gui et B_Gui peuvent etre changer.
Code : Tout sélectionner
;***********************************************************************************
;{- Initiation
;***********************************************************************************
InitKeyboard()
InitSprite()
InitSprite3D()
InitMouse()
OpenScreen(1024,768,32,"")
;}
;***********************************************************************************
;{- Stuff
;***********************************************************************************
Enumeration
#efface
#Mur
#herbe
#Pointeur
#Selection
#R_Hud
#B_Hud
EndEnumeration
Structure Map_struct
x.f
y.f
Bloc_Type.l
EndStructure
#MapW = 100 ;32;25
#MapH = 100 ;24;18
#TileSize = 32
Scrolling_X=0
Scrolling_Y=0
Scrolling_vitesse = 10.0
AffichPointeur = 0
AffichHerbe = 0
AffichMur = 0
AffichSelection = 0
AffichSelectionPointeur = 0
AffichSelectionMur = 0
AffichSelectionHerbe = 0
Global Dim Map.Map_struct(#MapW,#MapH)
For y = 0 To #MapH
For x = 0 To #MapW
Map(x,y)\x = x * #TileSize
Map(x,y)\y = y * #TileSize
Map(x,y)\Bloc_Type = #efface
Next x
Next y
;800/32
;600/32
;}
;***********************************************************************************
;{- Sprite
;***********************************************************************************
CreateSprite(#efface,32,32)
CreateSprite(#Mur,32,32)
StartDrawing(SpriteOutput(#Mur))
Box(0,0,32,32,RGB($41,$61,$F5))
For i = 0 To 100
Line(Random(32) , Random(32) , 10, 10, RGB($5E,$C4,$D9))
Next
StopDrawing()
CreateSprite(#herbe,32,32)
StartDrawing(SpriteOutput(#herbe))
Box(0,0,32,32,RGB($FA,$3D,$3D))
For i = 0 To 100
Plot(Random(31) , Random(31) , RGB($F9,$FF,$AE))
Next
StopDrawing()
CreateSprite(#Pointeur,34,34)
StartDrawing(SpriteOutput(#Pointeur))
DrawingMode(4)
Box(0,0,34 ,34 ,RGB($54,$F5,$50))
StopDrawing()
LoadSprite(#R_Hud,"r_hud.bmp")
LoadSprite(#B_Hud,"b_hud.bmp")
;}
;***********************************************************************************
;{- Loop
;***********************************************************************************
Repeat
ClearScreen(RGB(0,0,0) )
;affiche la map
For v=0 To #MapH
For u=0 To #MapW
DisplaySprite ( Map(u,v)\Bloc_Type , Map(u,v)\x - Scrolling_X , Map(u,v)\y - Scrolling_Y)
;DisplaySprite(Map(u+Scrolling_X,v+Scrolling_Y),u*#TileSize,v*#TileSize)
Next u
Next v
ExamineKeyboard()
DisplaySprite(#R_Hud,801,0)
DisplaySprite(#B_Hud,0,601)
DisplaySprite(#Mur,950 , 100) ;bleu
DisplaySprite(#herbe,950 , 150) ;rouge
DisplaySprite(#Pointeur,950 , 200)
;DisplaySprite(#Selection,0 , 0)
ExamineMouse()
x = MouseX()
y = MouseY()
If AffichPointeur = 0
DisplayTransparentSprite(#Pointeur,x-SpriteWidth(0)/100, y-SpriteHeight(0)/100)
TransparentSpriteColor(#Pointeur, RGB($0,$0,$0) )
EndIf
If MouseButton(1)
If x > 950 And y > 150 And y < 182 And x < 982
AffichHerbe = 1
AffichPointeur = 1
AffichMur = 0
EndIf
If x > 950 And y > 200 And y < 232 And x < 982 ;250
AffichPointeur = 0
AffichSelection = 0
AffichSelectionMur = 0
AffichSelectionHerbe = 0
EndIf
If x > 950 And y > 100 And y < 132 And x < 982
AffichPointeur = 1
AffichMur = 1
AffichHerbe = 0
EndIf
; test si dans la map
If x<#MapW*#TileSize And y<#MapH*#TileSize
tx=x/#TileSize
ty=y/#TileSize
If AffichHerbe
Map(tx,ty)\Bloc_Type = #herbe
ElseIf AffichMur
Map(tx,ty)\Bloc_Type =#Mur
EndIf
EndIf
EndIf
;Si bouton droit , on efface
If MouseButton(2)
; test si dans la map
If x<#MapW*#TileSize And y<#MapH*#TileSize ;And x > 0 And x > 800 And y > 0 And y < 600
tx=x/#TileSize
ty=y/#TileSize
Map(tx,ty)\Bloc_Type = #efface
EndIf
EndIf
If AffichPointeur = 1 And AffichMur = 1
DisplayTransparentSprite(#Mur, x-SpriteWidth(0)/100, y-SpriteHeight(0)/100)
AffichSelection = 1
AffichSelectionHerbe = 0
EndIf
If AffichHerbe = 1 And AffichPointeur = 1
DisplayTransparentSprite(#herbe, x-SpriteWidth(0)/100, y-SpriteHeight(0)/100)
AffichSelection = 2
AffichSelectionHerbe = 1
EndIf
If AffichSelection = 0
AffichSelectionPointeur = 1
EndIf
;If AffichSelectionPointeur = 1
; DisplaySprite(#Pointeur,210 , 130)
; EndIf
If AffichSelection = 1
AffichSelectionMur = 1
EndIf
If AffichSelectionMur = 1
DisplaySprite(#Mur,950 ,700)
EndIf
If AffichSelection = 2
AffichSelectionHerbe = 1
EndIf
If AffichSelectionHerbe = 1
DisplaySprite(#herbe,950 ,700)
EndIf
;Gestion du scrooling
;********************************************************
If KeyboardPushed ( #PB_Key_Left )
Scrolling_X-Scrolling_vitesse
EndIf
If KeyboardPushed ( #PB_Key_Right )
Scrolling_X+Scrolling_vitesse
EndIf
If KeyboardPushed ( #PB_Key_Down )
Scrolling_Y+Scrolling_vitesse
EndIf
If KeyboardPushed ( #PB_Key_Up )
Scrolling_Y-Scrolling_vitesse
EndIf
;********************************************************
;1024 - 800 ;224
;768 - 600 ;168
StartDrawing(ScreenOutput())
DrawText(950,650,"Current", #White,#Black)
DrawText(950,670," Tile :", #White,#Black)
StopDrawing()
;}
;***********************************************************************************
;{- Save N' Load
;***********************************************************************************
If KeyboardPushed(#PB_Key_F5)
If CreateFile(0, "C:\Map_1.map")
For v=0 To #MapH -1
For u=0 To #MapW -1
WriteLong(0,Map(u,v)\Bloc_Type)
Next u
Next v
CloseFile(0)
EndIf
EndIf
If KeyboardPushed(#PB_Key_F6)
If OpenFile(0, "C:\Map_1.map")
For v=0 To #MapH -1
For u=0 To #MapW -1
Map(u,v)\Bloc_Type =ReadLong(0)
Next u
Next v
CloseFile(0)
EndIf
EndIf
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
;}

Sur ce, Merci