
@Shadow : Toi aussi tu y a joué?

Code : Tout sélectionner
/****************************************************************
** **
** Name: AlphaChannel **
** Author: Andreas Falkenhahn **
** Version: 1.0 **
** Date: 31.10.04 **
** Interpreter: Hollywood 2.0 **
** Licence: Sample program for Hollywood **
** Function: Demonstrates alpha channels in Hollywood **
** **
** History: **
** **
** 1.0: (31.10.04) **
** **
** - initial release **
** **
****************************************************************/
/*
** Important! Check if the used Hollywood version is at least
** version 2.0!
*/
@VERSION 2,0
@BGPIC 1, "BG.jpg"
@BGPIC 3, "Capitol.jpg"
@BRUSH 1, "Hollywood2.png"
@BRUSH 2, "Info.png"
@BRUSH 4, "Capitol2.jpg"
@SPRITE 2, "Hollywood.png", {LoadAlpha = True}
@SPRITE 4, "text1a.png", {LoadAlpha = True}
/*
** Scrolls in the info text, waits for left mouse, and scrolls it out
*/
Function p_InfoText(f$)
LoadSprite(3, f$, {LoadAlpha = True})
MoveSprite(3, #CENTER, #BOTTOMOUT, #CENTER, #BOTTOM, #SLOWSPEED)
WaitLeftMouse
MoveSprite(3, #CENTER, #BOTTOM, #CENTER, #BOTTOMOUT, #SLOWSPEED)
EndFunction
/*
** PNG alpha channel demo
*/
Function p_Demo1()
Local done = False
CreateGradientBGPic(2, #LINEAR, #WHITE, $939393, 640, 480)
DisplayBGPic(2)
p_InfoText("text1.png")
MoveSprite(2, #LEFTOUT, #CENTER, #CENTER, #CENTER)
CreateBrush(5, 640, 480)
StartTimer(1)
For Local k = $939393 To 0 Step -$20000
SetFillStyle(#FILLGRADIENT, #LINEAR, #WHITE, k)
SelectBrush(5)
Box(0, 0, 640, 480)
EndSelect
DisplayBrush(5, 0, 0)
If k < $800000 And done = False
DisplaySprite(4, #CENTER, #BOTTOM)
done = True
EndIf
WaitTimer(1, 1000\10)
Next
Wait(100)
EndFunction
/*
** Alpha gradient demo
*/
Function p_Demo2()
Local startc = {$ff00ff, #RED, #BLACK, #LIME, #FUCHSIA}
Local endc = {$ffff00, #BLACK, #WHITE, #YELLOW, #BLUE}
Local step!, intensity!
DisplayBGPic(3)
p_InfoText("text2.png")
CreateBrush(5, 640, 480)
SetFillStyle(#FILLGRADIENT, #LINEAR, #BLUE, #BLACK)
SelectBrush(5)
Box(0, 0, 640, 480)
SetFillStyle(#FILLCOLOR)
EndSelect
SelectAlphaChannel(5)
step! = 255 / 640
intensity! = 255
For Local k = 0 To 639
SetAlphaIntensity(intensity!)
intensity! = intensity! - step!
Box(k, 0, 1, 480)
Next
EndSelect
DisplayBrushFX(5, 0, 0, #REVEALLEFT)
For Local k = 0 To 4
SetFillStyle(#FILLGRADIENT, #LINEAR, startc[k], endc[k])
SelectBrush(5)
Box(0, 0, 640, 480)
EndSelect
DisplayBrushFX(5, 0, 0, IIf(k % 2 = 1, #REVEALLEFT, #REVEALRIGHT))
Next
p_InfoText("text2a.png")
EndFunction
/*
** Simple radial crossfade
*/
Function p_Demo3()
DisplayBGPic(3)
p_InfoText("text3.png")
CreateBrush(5, 640, 480)
SelectAlphaChannel(4)
SetAlphaIntensity(0)
Cls
EndSelect
Local step! = 255 / 78
Local intensity! = 0
For Local k = 10 To 400 Step 5
SelectAlphaChannel(4)
SetAlphaIntensity(intensity!)
Circle(#CENTER, #CENTER, k)
EndSelect
intensity! = intensity! + step!
SelectBrush(5)
DisplayBGPicPart(3, 0, 0, 640, 480)
DisplayBrush(4, 0, 0)
EndSelect
DisplayBrush(5, 0, 0)
Next
EndFunction
/*
** Complex radial crossfade (many circles need to be drawn!)
*/
Function p_Demo4()
DisplayBGPic(3)
p_InfoText("text4.png")
CreateBrush(5, 640, 480)
SelectAlphaChannel(4)
SetAlphaIntensity(0)
Cls
EndSelect
Local step! = 255 / 39
Local intensity! = 0
For Local k = 10 To 400 Step 10
SelectAlphaChannel(4)
Local intensity1! = 0
Local step1! = intensity! / 25
For Local i = k + 100 To k Step -4
SetAlphaIntensity(intensity1!)
Circle(#CENTER, #CENTER, i)
intensity1! = intensity1! + step1!
Next
SetAlphaIntensity(intensity!)
Circle(#CENTER, #CENTER, k)
EndSelect
intensity! = intensity! + step!
SelectBrush(5)
DisplayBGPicPart(3, 0, 0, 640, 480)
DisplayBrush(4, 0, 0)
EndSelect
DisplayBrush(5, 0, 0)
Next
Wait(100)
EndFunction
/*
** Circle with alpha transparency
*/
Function p_Demo5()
DisplayBGPic(2)
p_InfoText("text5.png")
CreateBrush(5, 480, 480)
SelectBrush(5)
SetFillStyle(#FILLGRADIENT, #LINEAR, #YELLOW, #FUCHSIA, 45)
Box(0, 0, 480, 480)
EndSelect
SetFillStyle(#FILLCOLOR)
SelectAlphaChannel(5)
SetAlphaIntensity(0)
Cls
Local step! = 239 / 255
Local intensity! = 0
For Local k = 240 To 1 Step -1
intensity! = intensity! + step!
SetAlphaIntensity(intensity!)
Circle(#CENTER, #CENTER, k)
Next
EndSelect
DisplayBrush(5, #CENTER, #CENTER)
WaitLeftMouse
EndFunction
EscapeQuit(True)
SetFillStyle(#FILLCOLOR)
WaitLeftMouse
p_Demo1()
p_Demo2()
p_Demo3()
LoadSprite(3, "text3a.png", {LoadAlpha = True})
MoveSprite(3, #CENTER, #BOTTOMOUT, #CENTER, #BOTTOM, #SLOWSPEED)
done = False
StartTimer(1)
While done = False
If IsLeftMouse() = True
done = 1
ElseIf IsRightMouse() = True
done = 2
EndIf
WaitTimer(1, 1000\50)
Wend
MoveSprite(3, #CENTER, #BOTTOM, #CENTER, #BOTTOMOUT, #SLOWSPEED)
If done = 1 Then p_Demo4()
p_Demo5()
DisplayBGPic(2)
p_InfoText("text7.png")
p_InfoText("text6.png")
CreateBGPic(4, 640, 480)
DisplayBGPic(4)
; setup a table with some colors
colors = {#YELLOW, #MAROON, #GREEN, #OLIVE, #NAVY, #PURPLE, #TEAL, #GRAY, #SILVER, #RED, #LIME, #BLUE, #FUCHSIA, #AQUA}
SetFillStyle(#FILLCOLOR)
; create a brush with a yellow circle
CreateBrush(3, 101, 101)
SelectBrush(3)
Circle(0, 0, 50, #YELLOW)
EndSelect
; select brush's #3 alpha channel as output device
SelectAlphaChannel(3)
SetAlphaIntensity(0)
Cls
i = 0
; render circles with an decreasing transparency (= alpha intensity)
For k = 51 To 1 Step -1
Circle(#CENTER, #CENTER, k)
SetAlphaIntensity(i)
i = i + 5
Next
EndSelect
; convert this brush to a sprite!
CreateSprite(1, #BRUSH, 3)
MoveBrush(1, #LEFTOUT, 156, #CENTER, 156) ; show brush 1
MoveBrush(2, #CENTER, #BOTTOMOUT, #CENTER, 291) ; show brush 2
StartTimer(1)
InstallEventHandler({OnMouseMove =
Function(msg)
; draw the circle with alpha channel at the current pointer position!
DisplaySprite(1, msg.x, msg.y)
EndFunction})
SetInterval(1,
Function()
; change colors! alpha channel remains the same!
SelectBrush(3)
c = Wrap(c + 1, 0, ListItems(colors))
Cls(colors[c])
EndSelect
CreateSprite(1, #BRUSH, 3)
MovePointer(MouseX() + 1, MouseY()) ; cause OnMouseMove event
EndFunction, 2000) ; every 2 seconds
MovePointer(MouseX() + 1, MouseY()) ; cause OnMouseMove event
; endless loop
Repeat
WaitEvent
Forever
Code : Tout sélectionner
Declare je_suis_une_procedure()
Code : Tout sélectionner
CreateSprite(1,16,15)
Code : Tout sélectionner
;PARTIE 1 initialisation des variables du prg
; *********** initialisation *********
;coord de départ
x.f = 10
Y.f = 110
;vitesses de départ
vx.f = 10
vy.f = -45
pas.f=0.2
; ******************************
InitMouse()
InitKeyboard()
; ******** ** pour le sprite *****************
InitSprite()
; ***************************************
; PARTIE 2 Creation de la fenetre + son ecran integré
OpenWindow(1, 1,1, 800, 600, "test",#PB_Window_SystemMenu ) ; on ouvre une fenetre
OpenWindowedScreen(WindowID(1) , 0, 0, 800, 600, 1, 1, 1) ; on met un ecran dedans !!
; PARTIE 3 CREATION DES SPRITES
; *********** on va creer le sprite !! *****************
; on cree le sprite en avance
; il faut bien comprendre qu'un sprite est en fait une cellule vide qui peut se deplacer n'importe ou sur l'ecran
; et meme en dehors !!
CreateSprite(1,16,15) ; on cree un sprite (une cellule vide) de 16*16
StartDrawing(SpriteOutput(1)) ; on va dessiner dedans un rond jaune !
Circle(8,8, 8,RGB($F1,$F8,$C)) ; le voila le beau rond jaune
StopDrawing()
; ********* le sprite est terminé on va jouer avec !! ******
;PARTIE 4 LA BOUCLE DE GESTIONS DES EVENTS
Repeat ; boucle principale
Event= WaitWindowEvent() ; on regarde si quelqu'un a cliqué sur la croix pour quitter
ExamineMouse() ; on demande a purebasic de surveiller les event de souris !
ExamineKeyboard() ; on demande a purebasic de surveiller les event de clavier!
; ************************* ton prog ici ****************
For i = 1 To 1520
If MouseButton(2) Or KeyboardPushed(#PB_Key_All) ; le bouton de souris droit fait quitter ! ou bien n'importe quel touche
End
EndIf
vy = vy+10*pas ; ça va en gros simuler un rebond sur un sol invisible
x=x+vx*pas
Y=Y+vy*pas
DisplaySprite(1, x+10,Y+150) ; et voila on dessine le sprite (qui contien un rond jaune)!
If Y>120 ; gestion des rebonds en fonction de la valeur de y
vy=-vy*0.95 ; chgt de signe de la compo verticale de la vitesse
EndIf ;+ amortissement de 5% à chaque rebond
Next i
; ***************************************************
FlipBuffers()
;ClearScreen($0); <--- c'est la place normale pour le clearscreen !!
Until Event=#PB_Event_CloseWindow ; boucle temps que l'evenement de fenetre n'est pas #PB_Event_CloseWindow (un appuis sur la croix)
; Epb
j'ai fait partie du monde Atari mais sous le pseudo Dobroyogi a écrit :bonsoir zorro (je connais un zorro2 sur atari ste en demomaking