Flip sprite
- microdevweb
- Messages : 1800
- Inscription : mer. 29/juin/2011 14:11
- Localisation : Belgique
Flip sprite
Bonjour à tous,
Je trouve quand même vraiment malheureux qu'après autant d'année Freed n'aie toujours pas implémenté une fonction pour faire un flip d'un sprite.
Si vous avez des solutions je suis preneur
Je trouve quand même vraiment malheureux qu'après autant d'année Freed n'aie toujours pas implémenté une fonction pour faire un flip d'un sprite.
Si vous avez des solutions je suis preneur
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Work at Centre Spatial de Liège
Re: Flip sprite
Avec les machines d'aujourd'hui ce n'est pas très important coté ressources mais en amont ça éviterait tout de même de se faire une symétrie de ses images et/ou de clipspriter ses spriteSheets à gogo. Je suis en plein dedans pour un petit contest halloween.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Re: Flip sprite
Je suis tout a fait d'accord... il manque quelques trucs pour les sprites de base.. c'est dommage ...microdevweb a écrit :Bonjour à tous,
Je trouve quand même vraiment malheureux qu'après autant d'année Freed n'aie toujours pas implémenté une fonction pour faire un flip d'un sprite.
Si vous avez des solutions je suis preneur
Re: Flip sprite
TransformSprite() gère ça bien pourtant...
Et, par hasard, ZoomSprite avec un coefficient négatif...
Je ne comprends pas votre demande...
Et, par hasard, ZoomSprite avec un coefficient négatif...
Je ne comprends pas votre demande...
Re: Flip sprite
ça fonctionne avec transFormSprite() ? faut que je reteste, car avant ça fonctionnait uniquement en faisant une bidouille en assembleur pour activer le fait que si on retourne le sprite que ce ne soit pas transparent.Ollivier a écrit :TransformSprite() gère ça bien pourtant...
Et, par hasard, ZoomSprite avec un coefficient négatif...
Je ne comprends pas votre demande...
Re: Flip sprite
@microdevweb je suis plutot d'accord avec toi, mais en attendant, une solution alternative : http://forums.purebasic.com/english/vie ... 16&t=67701
Re: Flip sprite
Mon code source est dans la section Hors Sujet, tout comme un tas d'autres données, références et autres, qui représentent un tas d'heures d'investissement, réduit à la seule propriété de Fred, tout comme à ceux qui ont téléchargé ces mêmes codes sources, données et références. Donc c'est de mémoire que j'informe qu'effectivement TransformSprite() cache systématiquement les faces retournées.
Seulement, Idle m'avait mailé les possibilités de TransformSprite() : un quad affiché en forme de Z permet d'activer l'effet de perspective du texturing sous Windows seulement.
Donc le FlipSprite() est effectivement impossible avec TransformSprite().
Et un coefficient négatif avec ZoomSprite() ? Ça marche?
Seulement, Idle m'avait mailé les possibilités de TransformSprite() : un quad affiché en forme de Z permet d'activer l'effet de perspective du texturing sous Windows seulement.
Donc le FlipSprite() est effectivement impossible avec TransformSprite().
Et un coefficient négatif avec ZoomSprite() ? Ça marche?
- microdevweb
- Messages : 1800
- Inscription : mer. 29/juin/2011 14:11
- Localisation : Belgique
Re: Flip sprite
@boby,
Le problème avec ce code est qu'il ne fonctionne que dans le cas on l'on flip en horizontal et vertical
Exemple avec ce code (flèche droite flip vertical haut horizontal)
Le problème avec ce code est qu'il ne fonctionne que dans le cas on l'on flip en horizontal et vertical
Exemple avec ce code (flèche droite flip vertical haut horizontal)
Code : Tout sélectionner
; ***********************************************************************
; Project : FLIP SPRITE
; ORIGINAL CODE FROM : Comtois
; UPGRADER BY : microdevWeb
; ***********************************************************************
; GAME INITIALIZE
#MAIN_FORM = 0
If Not InitSprite()
MessageRequester("Game engine error","Cannot run sprite engine",#PB_MessageRequester_Error)
End
EndIf
If Not InitKeyboard()
MessageRequester("Game engine error","Cannot run keyboard engine",#PB_MessageRequester_Error)
End
EndIf
If Not OpenWindow(#MAIN_FORM,0,0,800,600,"Flappy bird",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
MessageRequester("Window engine error","Cannot open window",#PB_MessageRequester_Error)
End
EndIf
If Not OpenWindowedScreen(WindowID(#MAIN_FORM),0,0,800,600)
MessageRequester("Game engine error","Cannot open window screen",#PB_MessageRequester_Error)
End
EndIf
If Not InitSound()
MessageRequester("Game engine error","Cannot init sound engine",#PB_MessageRequester_Error)
End
EndIf
; FLIP FUNCTION
Procedure flipSprite(sprite,vertical.b,horizontal.b)
; default sprite vertices
; X1 X2
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x4 x3
Protected w = SpriteWidth(sprite),
h = SpriteHeight(sprite),
x1 = 0,
y1 = 0,
x2 = w,
y2 = 0,
x3 = w,
y3 = h,
X4 = 0,
y4 = h
If vertical
; X4 X3
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x1 x2
x1 = 0
y1 = h
x2 = 0
y2 = h
x3 = w
y3 = 0
X4 = 0
y4 = 0
EndIf
If horizontal
; X2 X1
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x3 x4
x1 = w
y1 = 0
x2 = w
y2 = 0
x3 = 0
y3 = h
X4 = w
y4 = h
EndIf
If vertical And horizontal
; X3 X4
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x2 x1
x1 = w
y1 = h
x2 = 0
y2 = h
x3 = 0
y3 = 0
X4 = w
y4 = 0
EndIf
; TransformSprite(1,167,34,0,34,0,0,167,0)
TransformSprite(sprite,x1,y1,x2,y2,x3,y3,x4,y4)
EndProcedure
#PB_SPRITE = 0
; load pureBasic Sprite
LoadSprite(#PB_SPRITE, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp")
Global gEvent,gExit.b,gHorizontal.b,gVertical.b,gKeyPushed.b
Repeat ; game loop
Repeat ; window loop
gEvent = WindowEvent()
If gEvent = #PB_Event_CloseWindow
gExit = #True ; exit to game loop
Break ; exit to window loop
EndIf
Until gEvent = 0
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
gExit = #True ; exit to game loop
EndIf
If KeyboardPushed(#PB_Key_Up) And Not gKeyPushed
; reverse horizontal flip
gHorizontal = ~ gHorizontal
gKeyPushed = #True
EndIf
If KeyboardPushed(#PB_Key_Right) And Not gKeyPushed
; reverse vertical flip
gVertical = ~ gVertical
gKeyPushed = #True
EndIf
If KeyboardReleased(#PB_Key_All)
gKeyPushed = #False
EndIf
ClearScreen(0)
flipSprite(#PB_SPRITE,gVertical,gHorizontal)
DisplayTransparentSprite(#PB_SPRITE,100,100)
FlipBuffers()
Until gExit
End
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Work at Centre Spatial de Liège
- microdevweb
- Messages : 1800
- Inscription : mer. 29/juin/2011 14:11
- Localisation : Belgique
Re: Flip sprite
Malheureusement nonOllivier a écrit : Et un coefficient négatif avec ZoomSprite() ? Ça marche?
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Work at Centre Spatial de Liège
- microdevweb
- Messages : 1800
- Inscription : mer. 29/juin/2011 14:11
- Localisation : Belgique
Re: Flip sprite
Voici un code qui fonctionne avec un gros bidouillage en asm qui désactive les faces cachée(pas de moi car je serais incapable de pondre ça)
Mais une chose aussi élémentaire qu'un flip devrait faire partie des commande de pureBasic
Code : Tout sélectionner
; ***********************************************************************
; Project : FLIP SPRITE
; ORIGINAL CODE FROM : Comtois/thyphoon/djes
; UPGRADED BY : microdevWeb
; ***********************************************************************
; GAME INITIALIZE
#MAIN_FORM = 0
If Not InitSprite()
MessageRequester("Game engine error","Cannot run sprite engine",#PB_MessageRequester_Error)
End
EndIf
If Not InitKeyboard()
MessageRequester("Game engine error","Cannot run keyboard engine",#PB_MessageRequester_Error)
End
EndIf
If Not OpenWindow(#MAIN_FORM,0,0,800,600,"Flappy bird",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
MessageRequester("Window engine error","Cannot open window",#PB_MessageRequester_Error)
End
EndIf
If Not OpenWindowedScreen(WindowID(#MAIN_FORM),0,0,800,600)
MessageRequester("Game engine error","Cannot open window screen",#PB_MessageRequester_Error)
End
EndIf
If Not InitSound()
MessageRequester("Game engine error","Cannot init sound engine",#PB_MessageRequester_Error)
End
EndIf
; setting flip asm
;Disable Backface Culling
;from : http://www.forums.purebasic.com/english/viewtopic.php?f=16&t=43718
Define pd3d.IDirect3DDevice9
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
EnableASM
!extrn _PB_Screen_Direct3DDevice
!MOV dword EAX, [_PB_Screen_Direct3DDevice]
!MOV dword [v_pd3d],EAX
DisableASM
CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64
EnableASM
!extrn PB_Screen_Direct3DDevice
!MOV dword EAX, [PB_Screen_Direct3DDevice]
!MOV dword [v_pd3d],EAX
DisableASM
CompilerElse
Debug "Unsupported processor"
End
CompilerEndIf
pd3d\SetRenderState(22,1)
pd3d\SetRenderState(7,0)
; FLIP FUNCTION
Procedure flipSprite(sprite,vertical.b,horizontal.b)
; default sprite vertices
; X1 X2
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x4 x3
Protected w = SpriteWidth(sprite),
h = SpriteHeight(sprite),
x1 = 0,
y1 = 0,
x2 = w,
y2 = 0,
x3 = w,
y3 = h,
X4 = 0,
y4 = h
If vertical
; X4 X3
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x1 x2
x1 = 0
y1 = h
x2 = w
y2 = h
x3 = w
y3 = 0
X4 = 0
y4 = 0
EndIf
If horizontal
; X2 X1
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x3 x4
x1 = w
y1 = 0
x2 = 0
y2 = 0
x3 = 0
y3 = h
X4 = w
y4 = h
EndIf
If vertical And horizontal
; X3 X4
; ---------
; | /|
; | / |
; | / |
; |/ |
; ---------
; x2 x1
x1 = w
y1 = h
x2 = 0
y2 = h
x3 = 0
y3 = 0
X4 = w
y4 = 0
EndIf
TransformSprite(sprite,x1,y1,x2,y2,x3,y3,x4,y4)
; TransformSprite(sprite,w,0,0,0,0,h,w,h)
EndProcedure
#PB_SPRITE = 0
; load pureBasic Sprite
LoadSprite(#PB_SPRITE, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp")
Global gEvent,gExit.b,gHorizontal.b,gVertical.b,gKeyPushed.b
Repeat ; game loop
Repeat ; window loop
gEvent = WindowEvent()
If gEvent = #PB_Event_CloseWindow
gExit = #True ; exit to game loop
Break ; exit to window loop
EndIf
Until gEvent = 0
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
gExit = #True ; exit to game loop
EndIf
If KeyboardPushed(#PB_Key_Right) And Not gKeyPushed
; reverse horizontal flip
gHorizontal = ~ gHorizontal
gKeyPushed = #True
EndIf
If KeyboardPushed(#PB_Key_Up) And Not gKeyPushed
; reverse vertical flip
gVertical = ~ gVertical
gKeyPushed = #True
EndIf
If KeyboardReleased(#PB_Key_All)
gKeyPushed = #False
EndIf
ClearScreen(0)
flipSprite(#PB_SPRITE,gVertical,gHorizontal)
DisplayTransparentSprite(#PB_SPRITE,100,100)
FlipBuffers()
Until gExit
End
Dernière modification par microdevweb le lun. 29/oct./2018 15:33, modifié 1 fois.
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Work at Centre Spatial de Liège
Re: Flip sprite
A plus les amis.
Re: Flip sprite
+1microdevweb a écrit :Je trouve quand même vraiment malheureux qu'après autant d'année Freed n'aie toujours pas implémenté une fonction pour faire un flip d'un sprite.
et egalement, "spriter" un sprite !!
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Re: Flip sprite
Heu ça veut dire quoi spriter un sprite...SPH a écrit :et egalement, "spriter" un sprite !!
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Re: Flip sprite
Dessiner un sprite dans un sprite. Avec ca, bonjour les effets speciaux !!Ar-S a écrit :Heu ça veut dire quoi spriter un sprite...SPH a écrit :et egalement, "spriter" un sprite !!
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Re: Flip sprite
Code : Tout sélectionner
StartDrawing(SpriteOutput())