20Zeiler: Bubu Butterfly's Spring Vacation
-
- Beiträge: 17389
- Registriert: 10.11.2004 03:22
-
- Beiträge: 17389
- Registriert: 10.11.2004 03:22
hab mal den ausführlichen Code auf 4.30 angepasst...
[edit]
Eventhändling ergänzt - sorry für die Schlamperei - Kaeru
Code: Alles auswählen
; ***
; *** Bubu Butterfly's Spring Vacation
; ***
; *** by Kaeru Gaman (c) 2005-02-13
; ***
; *** for the 20-liner contest
; *** formatted & commended version
; ***
; *** adopted for PB 4.30 ; 2009-03-13
; ***
#pf = 3.14159265/180 ; factor Deg -> Rad
Procedure Flower(x.l,y.l) ; draw flower
For i=0 To 5 ; 6 blossom leaves
Circle(x+12*Sin(i*60*#pf),y+12*Cos(i*60*#pf),8,RGB(128,0,48)) ; darker border
Circle(x+12*Sin(i*60*#pf),y+12*Cos(i*60*#pf),7,RGB(255,0,96)) ; fill color
Next
Circle(x,y,6,RGB(255,0,96)) ; center backgrnd
Circle(x,y,5,RGB(255,240,32)) ; yello center
EndProcedure
Procedure Bee(x.l,y.l,f.l) ; the Bee Enemy
For i=-2 To 1 ; striped
Circle(x,y-2+4*i,6,RGB(255,240,0)) ; in yello
Circle(x,y+4*i,6,RGB(32,32,0)) ; and 'black'
Next
Circle(x,y+6,5,RGB(255,192,0)) ; head
Circle(x+3,y+5,2,RGB(64,128,255)) ; eyes
Circle(x-3,y+5,2,RGB(64,128,255))
Circle(x-12,y-4-f,8,RGB(240,240,255)) ; wings, animated by the 'f'
Circle(x+12,y-4-f,8,RGB(240,240,255))
EndProcedure
Procedure Fly(x.l,y.l,f.l) ; the player butterfly
For i=0 To 3 ; 4 wings animated by the 'f'
Circle(x+f*Sin((45+i*90)*#pf),y+f*Cos((45+i*90)*#pf),7,RGB(16,160,255))
Circle(x+2*f*Sin((45+i*90)*#pf),y+2*f*Cos((45+i*90)*#pf),7,RGB(16,160,255))
Circle(x+f*Sin((45+i*90)*#pf),y+f*Cos((45+i*90)*#pf),4,RGB(255,240,32))
Circle(x+2*f*Sin((45+i*90)*#pf),y+2*f*Cos((45+i*90)*#pf),4,RGB(255,240,32))
Next
Circle(x,y-6,3,RGB(128,96,0)) ; body: upper end
Box(x-3,y-6,6,12,RGB(128,96,0)) ; and middle
Circle(x,y+6,3,RGB(128,96,0)) ; and lower end
Line(x-1,y-9,-6,-11,RGB(16,200,255)) ; two feelers
Line(x,y-9,5,-11,RGB(16,200,255))
Circle(x,y-9,3,RGB(255,96,0)) ; and a head
EndProcedure
; init for windowed mode
If InitSprite() And InitKeyboard() And OpenWindow(0,0,#PB_Ignore,800,600,"SV") And OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)
; init for fullscreen mode
;If InitSprite() And InitKeyboard() And OpenScreen(800,600,16,"SV")
SetFrameRate(60)
Dim PX(600) ; background-dots-coordinate
Dim FP(4) ; five flowers
For n=1 To 600 ; set start-coor for the background-dots
PX(n)=Random(799)
Next
LV=4 ; initial no. of lifes
Repeat ; this will be executed when new life
FX=400 ; Butterfly starting position
FY=500
LV-1 ; decrement lifes
NW=0 ; reset next-life-flag
Repeat ; this will be executed until new life
Repeat
Event = WindowEvent()
Until Event = 0 Or Event = #PB_Event_CloseWindow
ExamineKeyboard()
ClearScreen( $008000 )
; cursor-keys check
If KeyboardPushed(#PB_Key_Up) ; UP
FY-2
EndIf
If KeyboardPushed(#PB_Key_Left) ; LEFT
FX-2
EndIf
If KeyboardPushed(#PB_Key_Right) ; RIGHT
FX+2
EndIf
If KeyboardPushed(#PB_Key_Down) ; DOWN
FY+2
EndIf
StartDrawing(ScreenOutput())
DrawingMode(1) ; transparent background for text
PX(0)=Random(799) ; new dot
For n=600 To 1 Step -1 ; all dots
PX(n)=PX(n-1) ; scroll them
Box(PX(n),n-1,2,1,RGB(0,192,0)) ; draw them
Next
For n=0 To 4 ; all flowers
If Abs(FP(n)-100-FX)<16 And Abs(c+150*n-50-FY)<16 ; collision check
FP(n)=0 ; hide flower
SC+10 ; add score
EndIf
Flower(FP(n)-100,c+150*n-50) ; draw flower scrolled by counter
Next
; show the title
DrawText(270,10,"Bubu Butterfly's Spring Vacation", $60FF40)
; show score and lifes
DrawText(270,580,"Score: "+Right("000000"+Str(SC),6)+" Lifes: "+Str(LV), $60FF40)
Fly(FX-DI,FY,6+3*Sin(c/8)) ; draw butterfly with anim wings
Bee(BX+400+100*Sin(c/20),c*4,4*Sin(c)) ; draw bee with anim wings
If Abs(BX+400+100*Sin(c/20)-(FX-DI))<24 And Abs(c*4-FY)<24 ; Bee-collision
DI=10000 ; hide the Butterfly
EndIf
c+1 ; counter
If c>149 ; next phase
For n=4 To 1 Step -1 ; set flowers 1 further
FP(n)=FP(n-1)
Next
FP(0)=150+Random(700) ; new flower
BX=Random(600)-300 ; new bee
If DI=10000 ; butterfly hidden?
NW=1 ; next life
DI=0 ; unhide butterfly
EndIf
c=0 ; reset counter
EndIf
StopDrawing()
Delay(8) ; don't occupy CPU to 100%
; alternate check for window-mode
;If KeyboardPushed(1) Or LV<0 Or WindowEvent() = #PB_Event_CloseWindow
; check ESC and lives
If KeyboardPushed(#PB_Key_Escape) Or LV<0 Or Event = #PB_Event_CloseWindow
EX=1 ; set exit-flag, if ESC or Win-Close or zero lifes
EndIf
FlipBuffers()
Until EX=1 Or NW=1 ;leave inner loop when EXIT or next life
Until EX=1 ; leave program only when EXIT
EndIf ; the ENDIF of the INIT: whole prog will only be executed when INIT succeeds
MessageRequester("End'O'Game","Your Score:"+ #CRLF$ +Str(SC)+" pouches of pollen",#MB_ICONINFORMATION)
End ; huahuahua that's all folks
[edit]
Eventhändling ergänzt - sorry für die Schlamperei - Kaeru
Zuletzt geändert von Kaeru Gaman am 15.03.2009 18:43, insgesamt 2-mal geändert.
Der Narr denkt er sei ein weiser Mann.
Der Weise weiß, dass er ein Narr ist.
Der Weise weiß, dass er ein Narr ist.
-
- Beiträge: 17389
- Registriert: 10.11.2004 03:22
probier jetzt noch mal....
hatte damals kein sauberes eventhändling drin, und habs bei der ersten umsetzung auch vergessen.
das Windowed war ursprünglich auch nur ne "Bonus Feature" für leute die keinen Fullscreen mögen.
habs nur diesmal gleich windowed gemacht,
weil das Umschalten der Auflösung beim Fullscreen so lange dauert,
dass der Player schon zwei mal gestorben ist bis das Bild zu sehen ist...
hatte damals kein sauberes eventhändling drin, und habs bei der ersten umsetzung auch vergessen.
das Windowed war ursprünglich auch nur ne "Bonus Feature" für leute die keinen Fullscreen mögen.
habs nur diesmal gleich windowed gemacht,
weil das Umschalten der Auflösung beim Fullscreen so lange dauert,
dass der Player schon zwei mal gestorben ist bis das Bild zu sehen ist...
Der Narr denkt er sei ein weiser Mann.
Der Weise weiß, dass er ein Narr ist.
Der Weise weiß, dass er ein Narr ist.
-
- Beiträge: 17389
- Registriert: 10.11.2004 03:22