Dog (demo 2D)

Advanced game related topics
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Dog (demo 2D)

Post by SPH »

http://xmas.free.fr/demo_dog.zip

Code: Select all

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Erreur", "Impossible d'initialiser l'écran.")
  End
EndIf
If InitSound() = 0
  MessageRequester("Error", "Sound system not available.") : End
EndIf

LoadMusic(0, "MOD.mod")


ExamineDesktops()
ddw=DesktopWidth(0)
ddh=DesktopHeight(0)

If OpenScreen(ddw,ddh,32,"DOG")=0
  MessageRequester("Erreur", "Impossible d'ouvrir l'écran.")
  End
EndIf

If LoadSprite(0,"dog.bmp")=0
  MessageRequester("Erreur", "Image introuvable.")
  End
EndIf

ClearScreen(0)





xxx.f=1.4
yyy.f=1.1
rx.f=200
ry.f=220
oldyyy=0
deca=0


FlipBuffers()
Delay(1000)

LoadFont (0, "Courier", 30)            ; Load Courrier Font, Size 15

For i= 5 To 255 Step 5
  StartDrawing(ScreenOutput())
  DrawingMode(0)                          ; Transparent TextBackground
  DrawingFont(FontID(0))                  ; Use the 'Courier' font
  DrawText(ddw/2-30,ddh/2-4, "DOG", RGB(i,i,i))
  StopDrawing() 
  FlipBuffers()
  Delay(1)
Next
Delay(2000)

For i= 250 To 0 Step -10
  StartDrawing(ScreenOutput())
  DrawingMode(0)                          ; Transparent TextBackground
  DrawingFont(FontID(0))                  ; Use the 'Courier' font
  DrawText(ddw/2-30,ddh/2-4, "DOG", RGB(i,i,i))
  StopDrawing() 
  FlipBuffers()
  Delay(1)
Next


ClearScreen(0)
FlipBuffers()

;;;;;;;;;;;;;;;;;;;;;;;;

ClipSprite(0,0,0,514,604)
DisplaySprite(0,0,0)

Dim p(514,604)
Dim p2(514,604)


StartDrawing(ScreenOutput())
For i=0 To 514
  For u=0 To 604
    p(i,u)=Point(i,u)
    p2(i,u)=p(i,u)
  Next
Next
StopDrawing() 
ClearScreen(0)


;;;;;;;;;;


; LoadFont (0, "Courier", 30)            ; Load Courrier Font, Size 15
StartDrawing(ScreenOutput())
DrawingMode(0)                          ; Transparent TextBackground

DrawingFont(FontID(0))                 ; Use the 'Courier' font
DrawText(ddw/2+ddw/64,ddh/2-46, "Code : SPH", RGB(255, 255,255))    ; Print our text
DrawText(ddw/2+ddw/64,ddh/2+0, "GFX : Cougar", RGB(255, 255,255))   ; Print our text
DrawText(ddw/2+ddw/64,ddh/2+46, "Music : Tristan LORACH", RGB(255, 255,255))    ; Print our text
                                                                                ; Box(ddw/2+ddw/64,ddh/2-46,530,130,RGB(255,0,0))
StopDrawing() 
GrabSprite(1,ddw/2+ddw/64,ddh/2-46,530,130)


temps= ElapsedMilliseconds()

;Goto la

PlayMusic(0)








;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)
  FlipBuffers()
  DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)
  FlipBuffers()
  
Repeat
  If all=0
    ClipSprite(0,0,0,514,604)
    DisplaySprite(0,120,ddh/8-50)
  EndIf
  
;   DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)
  
  If ElapsedMilliseconds()-temps>7950
    Goto la4
  EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  
  For i=600+ddh/8 To 600+200+ddh/8
    ;    Debug Cos(Radian(yyy))*ry
    u=Cos(Radian(yyy+i*3))*ry+Sin(Radian(xxx+i*2))*rx
    If u>604
      u-604
    EndIf
    If u<0
      u+604
    EndIf

    
    ClipSprite(0,0,u,514,1)
    DisplaySprite(0,120,i)
    yyy+0.1
  Next
  
  
  xxx=oldxxx+3.14
  oldxxx=xxx
  yyy=oldyyy+2.74
  oldyyy=yyy
  
  FlipBuffers() 
  ExamineKeyboard()
  
Until KeyboardPushed(#PB_Key_Escape)
End

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

la4:
u= 604
;    DisplaySprite(0,120,ddh/8-50)
Repeat
  
  StartDrawing(ScreenOutput())
  For i=0 To 514
    LineXY(i+120,u+ddh/8-50,i+120,ddh,p(i,u))
  Next
  StopDrawing() 
  FlipBuffers()
  ExamineKeyboard()
  
  u-2
Until u<0 Or KeyboardPushed(#PB_Key_Escape)

If u>=0
  End
EndIf



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;






Repeat
  
  For i=0 To ddh-1
    
    u=Cos(Radian(yyy+i/5))*ry+Cos(Radian(xxx))*rx
    
    If u>604
      u-604
    EndIf
    If u<0
      u+604
    EndIf
    ClipSprite(0,0,u,514,1)
    DisplaySprite(0,120,i)
    yyy+0.35
    ;     ry+1
    
  Next
  
  
  xxx=oldxxx+1.14
  oldxxx=xxx
  yyy=oldyyy+0.74
  oldyyy=yyy
  
  ;  End  
  If ElapsedMilliseconds()-temps>27000
    Goto la5
  EndIf
  
  
  FlipBuffers() 
  ExamineKeyboard()
  
Until KeyboardPushed(#PB_Key_Escape)

End

la5:









;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




;;;;; 2 ;;;;;
la:


ClipSprite(0,0,0,514,604)

ClearScreen(0)
DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)

FlipBuffers()
ClearScreen(0)
DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)

sq2=0
;;;;;;;;;;;
Repeat
  
  
  StartDrawing(ScreenOutput())
  For i=0 To 514
    For u=0 To 604
      rvb=p2(i,u)
      r.w=Red(rvb)
      If r>01
        r-2
      EndIf
      v.w=Green(rvb)
      If v>01
        v-2
      EndIf
      b.w=Blue(rvb)
      If b>01
        b-2
      EndIf
      p2(i,u)=RGB(r,v,b)
      rvb=(r+v+b)/3
      Plot(i+Random(sq2)-sq2/2+120,u+Random(sq2)-sq2/2+ddh/8,RGB(rvb,rvb,rvb))
      
    Next
  Next
  StopDrawing() 
  
  sq2+1
  
  FlipBuffers() 
  If sq2=1
    Delay(2000)
  EndIf
  
  
  ExamineKeyboard()
Until sq2>108 Or KeyboardPushed(#PB_Key_Escape)

If sq2<108
  End
EndIf


x1.f=10
y1.f=51
x2.f=100
y2.f=78
x3.f=23
y3.f=91

Dim r(514,604)
Dim v(514,604)
Dim b(514,604)

cmb=0

ClearScreen(0)
DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)

FlipBuffers()
ClearScreen(0)
DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)


Repeat
  
;   DisplaySprite(1,ddw/2+ddw/64,ddh/2-46)
  StartDrawing(ScreenOutput())
  
  
  For i=-20 To 30
    For u=-20 To 30
      
      xx1=i+257+Cos(Radian(x1))*120-Cos(Radian(x2))*120
      yy1=u+302+Sin(Radian(y1))*150+Cos(Radian(x2))*150
      xx2=i+257+Cos(Radian(x2))*120+Cos(Radian(x3))*120
      yy2=u+302+Cos(Radian(y2))*150-Sin(Radian(x3))*150
      xx3=i+257+Cos(Radian(x3))*120+Cos(Radian(x1))*120
      yy3=u+302+Sin(Radian(y3))*150+Sin(Radian(x1+y1))*150
      
      If xx1>0 And xx1<514
        If yy1>0 And yy1<604
          r(xx1,yy1)=Red(p(xx1,yy1))
          ;           ok1=1
          Plot(xx1+120,yy1+ddh/8,RGB(r(xx1,yy1),v(xx1,yy1),b(xx1,yy1)))
        EndIf
      EndIf
      If xx2>0 And xx2<514
        If yy2>0 And yy2<604
          v(xx2,yy2)=Green(p(xx2,yy2))
          ;           ok2=1
          Plot(xx2+120,yy2+ddh/8,RGB(r(xx2,yy2),v(xx2,yy2),b(xx2,yy2)))
        EndIf
      EndIf
      If xx3>0 And xx3<514
        If yy3>0 And yy3<604
          b(xx3,yy3)=Blue(p(xx3,yy3))
          ;           ok3=1
          Plot(xx3+120,yy3+ddh/8,RGB(r(xx3,yy3),v(xx3,yy3),b(xx3,yy3)))
        EndIf
      EndIf
      
      
    Next
  Next
  
  StopDrawing() 
  
  x1+1.2
  y1+0.52
  x2+0.7
  y2+1.14
  x3+1.35
  y3+0.88
  cmb+1
  
  
  FlipBuffers() 
  ExamineKeyboard()
  
Until cmb>2100 Or KeyboardPushed(#PB_Key_Escape)

If cmb<2100
  End
EndIf


FlipBuffers()
ClearScreen(0)
FlipBuffers()
ClearScreen(0)
Delay(500)

LoadFont (0, "Courier", 30)            ; Load Courrier Font, Size 15

For i= 5 To 255 Step 5
  StartDrawing(ScreenOutput())
  DrawingMode(0)                          ; Transparent TextBackground
  DrawingFont(FontID(0))                  ; Use the 'Courier' font
  DrawText(ddw/2-250,ddh/2-4, "Thanks for watching", RGB(i,i,i))
  StopDrawing() 
  FlipBuffers()
  Delay(1)
Next
Delay(2000)

For i= 250 To 0 Step -10
  StartDrawing(ScreenOutput())
  DrawingMode(0)                          ; Transparent TextBackground
  DrawingFont(FontID(0))                  ; Use the 'Courier' font
  DrawText(ddw/2-250,ddh/2-4, "Thanks for watching", RGB(i,i,i))
  StopDrawing() 
  FlipBuffers()
  Delay(1)
Next

Delay(500)

End


; IDE Options = PureBasic 5.70 LTS (Windows - x86)
; CursorPosition = 235
; FirstLine = 392
; EnableXP
; Executable = dog.exe
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Dog (demo 2D)

Post by BarryG »

Nice water reflection effect!
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Dog (demo 2D)

Post by SPH »

BarryG wrote:Nice water reflection effect!
Yes :idea:

Thx :wink:
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Dog (demo 2D)

Post by Kwai chang caine »

Very nice :shock:
I like all, the "ouaf" :mrgreen: , the music and the animation :D
Thanks for sharing and congratulation at all creators 8)
ImageThe happiness is a road...
Not a destination
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Dog (demo 2D)

Post by dige »

Wow! Nice FX!
"Daddy, I'll run faster, then it is not so far..."
Post Reply