Probleme avec Point(x,y)
Publié : dim. 14/nov./2010 14:11
Probleme a 10 millions de dollards :
Ligne 73, quand on appuie sur le 0 du pavé numerique, la valeur COLOR prend la valeur du pixel sous le pointeur. Et pourtant, chez moi, ca prend la valeur 0 et je ne comprend pas !!!!
(il faut mettre une image a la ligne 37)
Ligne 73, quand on appuie sur le 0 du pavé numerique, la valeur COLOR prend la valeur du pixel sous le pointeur. Et pourtant, chez moi, ca prend la valeur 0 et je ne comprend pas !!!!
(il faut mettre une image a la ligne 37)
Code : Tout sélectionner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Another earth
; SPH(2010)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
InitSprite()
InitKeyboard()
InitMouse()
#dw=1024
#dh=768
#dc=32
UseJPEGImageDecoder()
If OpenScreen(#dw,#dh,#dc,"Another Earth")=0
MessageRequester("Erreur", "Screen Open ("+Str(#dw)+","+Str(#dh)+",32) : impossible à ouvrir", 0) : End
EndIf
nb=256
key=1
mode=2
Dim bank.w(9000000)
nb_total_polygon=0
ici_bank=0
bank(ici_bank)=nb_total_polygon : ici_bank+1
Dim ps.Point(nb-1) ; Array of 5 POINT structures
Dim ps2.Point(nb-1) ; Array of 5 POINT structures
; For p=0 To nb-1
; ps(p)\x=Random(1024)
; ps(p)\y=Random(768)
; Next p
cmb=0
LoadImage(0,"c:\Documents And Settings\SPH\Mes documents\Mes images\1.jpg")
;CreateSprite(0,#dw,#dh)
ResizeImage(0,#dw,#dh)
StartDrawing(ScreenOutput())
DrawImage(ImageID(0), 0,0)
StopDrawing()
GrabSprite(0,0,0,#dw,#dh)
FreeImage(0)
color=RGB(255,255,255)
chm$="d:/polygons/1.poly"
If OpenFile(0, chm$) ; Ouvre un fichier existant ou en crée un nouveau s'il n'existait pas
l=Lof(0)
CloseFile(0)
If l>0
Debug("Fichier existant")
;End
EndIf
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Repeat
DisplaySprite(0,0,0)
ExamineMouse()
mx=MouseX()
my=MouseY()
Mb_Right=MouseButton(#PB_MouseButton_Right)
Mb_Left=MouseButton(#PB_MouseButton_Left)
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Pad0)
StartDrawing(ScreenOutput())
color=Point(mx,my)
StopDrawing()
EndIf
If Mb_left
ps(cmb)\x=mx
ps(cmb)\y=my
cmb+1
If cmb>245
Beep_(800,50)
EndIf
Repeat
ExamineMouse()
Mb_Left=MouseButton(#PB_MouseButton_Left)
Until Mb_Left=0
EndIf
If Mb_Right
cmb-1
If cmb<0
cmb=0
EndIf
Repeat
ExamineMouse()
Mb_Right=MouseButton(#PB_MouseButton_Right)
Until Mb_Right=0
EndIf
If KeyboardPushed(#PB_Key_Space)
mode+1
mode%3
ExamineKeyboard()
While KeyboardPushed(#PB_Key_Space)
ExamineKeyboard()
Wend
EndIf
If mode=2
; For i=0 To ici_bank+4
; Debug bank(i)
; Next
; End
la=1
For i=1 To bank(0)
u=bank(la)
; Dim ps2.Point(nb-1) ; Array of 5 POINT structures
la+1
If bank(la)<>-1
Debug "bank<>-1":End
EndIf
la+1
rvb=RGB(bank(la),bank(la+1),bank(la+2))
la+3
For p=0 To u
ps2(p)\x=bank(la):la+1
ps2(p)\y=bank(la):la+1
Next p
hDC=StartDrawing(ScreenOutput())
Box(0,0,0,0,rvb) ; Would be nice to have a Cls() facility !!!
SetWindowOrgEx_(hDC,00,00,#Null) ; Move origin downwards
Polygon_(hDC,@ps2(0),u+1)
StopDrawing()
Next
EndIf
If (KeyboardPushed(#PB_Key_Return) Or KeyboardPushed(#PB_Key_PadEnter)) And cmb>1
bank(ici_bank) =cmb-1 : ici_bank+1
bank(ici_bank) =-1 : ici_bank+1
bank(ici_bank) =Red(color) : ici_bank+1
bank(ici_bank) =Green(color) : ici_bank+1
bank(ici_bank) =Blue(color) : ici_bank+1
For i=0 To cmb-1
bank(ici_bank) = ps(i)\x : ici_bank+1
bank(ici_bank) = ps(i)\y : ici_bank+1
Next
bank(0)+1
;DisplaySprite(0,0,0)
hDC=StartDrawing(ScreenOutput())
Box(0,0,0,0,color) ; Would be nice to have a Cls() facility !!!
SetWindowOrgEx_(hDC,00,00,#Null) ; Move origin downwards
;FrontColor(color)
Polygon_(hDC,@ps(0),cmb)
StopDrawing()
;GrabSprite(0,0,0,#dw,#dh)
cmb=0
;Delay(500)
ExamineKeyboard()
While KeyboardPushed(#PB_Key_Return) Or KeyboardPushed(#PB_Key_PadEnter)
ExamineKeyboard()
Wend
key+1
EndIf
If KeyboardPushed(#PB_Key_F5)
CreateFile(0, chm$)
For i=0 To ici_bank
WriteWord(0,bank(i))
Next
CloseFile(0)
End
EndIf
;temps = ElapsedMilliseconds()
; Define drawing area
hDC=StartDrawing(ScreenOutput())
Box(0,0,0,0,color) ; Would be nice to have a Cls() facility !!!
If mode>0
SetWindowOrgEx_(hDC,00,00,#Null) ; Move origin downwards
Polygon_(hDC,@ps(0),cmb)
EndIf
LineXY(mx,0,mx,#dh,RGB(255,0,0))
LineXY(0,my,#dw,my,RGB(255,0,0))
Plot(mx,my,RGB(0,255,0))
StopDrawing()
;temps = ElapsedMilliseconds()-temps
;Debug temps
;End
LoadFont(1, "Arial", 8)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(1))
DrawText(0,0," Polyg. : "+Str(key)+" - Point : "+Str(cmb)+" ", RGB(255,255,255))
DrawText(0,15," Mode : "+Str(mode)+" ", RGB(255,255,255))
Box(0,30,30,15,color)
StopDrawing()
FlipBuffers()
;Delay(4)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;;;;;;;;;;;;;;;