Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ~Ar-S~

Pages: 1 2 [3]
41
Purebasic / Re: Vectorbobs library for Purebasic
« on: October 15, 2015 »
Great work ! Thanks :clap:

42
Purebasic / PB vs The World (15'years PB contest)
« on: October 15, 2015 »
PB vs THE WORLD

I make this code because there is a (fun) contest to celebrate the 15th birthday of PB http://www.purebasic.fr/english/viewtopic.php?f=14&t=63307#p471729


Style : shoot em up
- I used Musik Maker jam to make the music and soundforge for the samples
- i also used a sprite from http://millionthvector.blogspot.fr (free sprites) for the ship (not the shield) andn the planet
- I used the old rules 80x80 with my code :)
- Try with succes on Windows and MacOS

EnJoY

Datas :http://pb.ldvmultimedia.com/PB_vs_THE_WORLD_by_Ar-S.zip

Code: [Select]
    ;*****************************************************************************
    ;*
    ;* Birthday Punch : PureBasic 15 years of happiness
    ;* PureBasic 5.31 x86
    ;* 192 lines of 80 chars of code or data as you want
    ;*
    ;* Name     : PB vs THE WORLD
    ;* Author   : Ar-S - Music made with Music Maker Jam - thanks to Microdevweb for shoot linkedlist() helping
    ;* Date     : Nov/Oct 2015
    ;* Notes    : Dedicated To my mom Apr 1940 - Sept 2015
    ;*
    MessageRequester("Info","Use Arrows to move, space to shoot and left ctrl to use shield"+Chr(10)+"Left Mouse Button to restart"+Chr(10)+Chr(10)+"Fleches pour se diriger, ctrl : bouclier, Espace:Feu, Bouton de gauche souris pour recommencer",#PB_MessageRequester_Ok) ; LIGNE NON PRIS EN COMPTE
         
    UseOGGSoundDecoder():Macro m:Macro:EndMacro:m dec:decoder():EndMacro
    m e:examine:EndMacro:m s(n,l,h,x,y):EndMacro:m _s:Structure:EndMacro
    InitSprite():InitKeyboard():InitMouse():UseOGGSound#dec:UsePNGImage#dec
    InitSound()
    _S BB:x.i:y.i:ID.b:End#_S:_S SP:x.i:y.i:n.i:LL.i:HH.i:v.b:r.f:End#_S
    _S St:x.i:y.i:v.b:n.b:End#_S:_S SN:D.i:F.i:End#_S:M R:random:EndMacro:M P(S)
    PlaySound(S,#PB_Sound_MultiChannel,70):EndMacro:M PP(S):PlaySound(S,1,80)
    EndMacro:m _k(k):KeyboardPushed(k):EndMacro
    M CS(n,x,y,l,h):ClipSprite(n,x,y,l,h):sp(n)\LL=l/2
    sp(n)\HH=h/2:ZoomSprite(n,l/2,h/2):v(n):EndMacro:m v(n):sp(n)\v = R(6,2)
    EndMacro:m SX(n):sp(n)\x:EndMacro:m SY(n):sp(n)\y:EndMacro:M Redo(n)
    SX(n)=820:SY(n)=R(500,100):v(n):EndMacro:m EX(n):St(n)\x:EndMacro
    m EY(n):St(n)\y:EndMacro:m EN(Z):St(Z)\n:EndMacro:m EV(n):St(n)\v
    EndMacro:m _r(n,d):SpriteQuality(1):RotateSprite(n,d,#PB_Absolute):EndMacro
    Global NewList BB.BB():Global F=LoadFont(16, "Arial", R(80,50))
    Global F1=LoadFont(17, "Arial", 24):Global.b feu,NF,ENNEMI,VIZ,ShotOn.b=#True
    Global.i x,y,xi,T:Global SCORE,LIFE:Global Dim sp.SP(16):Global Dim st.st(100)
    Global TimeElapset=ElapsedMilliseconds()
    LoadSound(20,"01.ogg"):LoadSound(21,"02.ogg"):LoadSound(22,"03.ogg")
    LoadSound(23,"04.ogg"):SCORE=0:LIFe=3:x=150:y=350:NF=9:xi=2500
    t1$="PURE BASIC VS THE WORLD !":t2$="HAPPY PURE BIRTHDAY"
    For i=0 To 100:EX(i)=R(820):EY(i)=R(600):Next:For i=0 To 20:EN(i)=13:EV(i)=3
    Next:For i=21 To 60:EN(i)=14:EV(i)=6:Next:For i=61 To 100:EN(i)=15:EV(i)=10
    Next:OpenScreen(800,600,32,"PB VS The WORLD", #PB_Screen_SmartSynchronization)
    LoadSprite(0,"im.png",8|4):For i=1 To 15:CopySprite(0,i,8|4):Next
    CS(1,7,142,232,133):CS(2,289,135,234,139):CS(3,0,1,129,128):CS(4,129,1,128,128)
    CS(5,257,0,118,130):CS(6,379,0,101,131):CS(7,478,1,115,130):CS(8,595,8,250,126)
    CS(9,533,213,53,62):ClipSprite(10,675,138,140,136):CS(11,606,231,25,43)
    CS(12,631,231,25,43):CS(13,840,266,8,8):CS(14,833,270,6,5):CS(15,824,271,3,3)
    FreeSprite(0)
    txt.s=t1$:xtx=r(500,100):ColT=RGB(R(255),R(255),R(255)):sx(10)=1500
    sy(10)=r(460,140):PS=1:Repeat:StartTime.i=ElapsedMilliseconds():ClearScreen(0)
    E#Mouse():E#Keyboard():If ElapsedMilliseconds()-TimeElapset>=350:ShotOn=#True
    TimeElapset=ElapsedMilliseconds():EndIf:If GO=0:If PS=1:PP(23):ps+1:EndIf
    For i=0 To 100:DisplayTransparentSprite(R(15,13), EX(i), EY(i),255):EX(i)-EV(i)
    If EX(i)<0:EX(i)=805:ey(i)=R(600):EndIf:Next
    DisplayTransparentSprite(10,SX(10),SY(10),255):StartDrawing(ScreenOutput())
    DrawingFont(f):DrawingMode(#PB_2DDrawing_Transparent):If xi< -2500:NT+1:If NT<2
    txt.s=t1$:ElseIf NT=2:txt.s=t2$:Else:NT=0:EndIf:xi=2500:xtx=r(500,100)
    ColT=RGB(R(255),R(255),R(255)):EndIf:DrawText(xi,xtx,txt.s,ColT,$0)
    StopDrawing():Xi-6:sx(2)=sx(1):sy(2)=sy(1):For S=3 To 8
    DisplayTransparentSprite(S, SX(S), SY(S),255):Next:If _K(#PB_Key_Up):y-5:ViZ=1
    If _K(#PB_Key_Left):x-5:ViZ=0:ElseIf _K(#PB_Key_Right):X+5:ViZ=1:EndIf
    ElseIf _K(#PB_Key_Down):y+5:ViZ=1:If _K(#PB_Key_Left):x-5:ViZ=0
    ElseIf _K(#PB_Key_Right):X+5:ViZ=1:EndIf:ElseIf _K(#PB_Key_Left):x-5:VIZ=0
    ElseIf _K(#PB_Key_Right):SX(1)=x:x+5:ViZ=1:EndIf:If y<25:y=25:ElseIf y>530
    y=530:EndIf:If x<0:x=0:ElseIf x>700:x=700:EndIf:SX(1)=x:Sy(1)=y:Sx(11)=x-10
    Sy(11)=y+23:Sx(12)=Sx(11):Sy(12)=Sy(11):If _k(#PB_Key_Space) And ShotOn
    AddElement(BB()):BB()\X=SX(1)+120:BB()\Y=SY(1)+15:BB()\ID=9:ShotOn=#False:P(20)
    EndIf:If _K(#PB_Key_LeftControl):shield=1:P(22):Else:shield=0:EndIf
    If shield=0:ship=1:Else:ship=2:EndIf:DisplayTransparentSprite(ship,x,y,255)
    RE=R(12,11):DisplayTransparentSprite(RE,sx(RE),Sy(RE),200):ForEach BB()
    BB()\X + 6:DisplayTransparentSprite(BB()\ID, BB()\X, BB()\Y,255):Next     
    For ENNEMI=3 To 8:ForEach BB()
    If SpriteCollision(9,BB()\X,BB()\Y,ENNEMI,sx(ENNEMI),sy(ENNEMI))<>0
    T=ENNEMI:SCORE+1:redo(ENNEMI):If ListSize(BB())>0:DeleteElement (BB()):EndIf
    P(21):EndIf:Next:Next:If ListSize(BB())>0 And BB()\X>810:DeleteElement (BB())
    EndIf:For i=3 To 8:SX(i)-sp(i)\v:SpriteQuality(1)
    RotateSprite(i, ROT.f,#PB_Absolute):ROT.f-0.5:If SX(i)< -100:redo(i):EndIf
    Next:For COL=3 To 8:If SpriteCollision(1,sx(1),sy(1),COL,sx(col),sy(col))<>0
    If shield=1:score-1:If Score<=0:Score=0:EndIf:ElseIf shield=0:life-1:If Life<=0
    GO=1:EndIf:EndIf:P(21):redo(col):EndIf:Next:StartDrawing(ScreenOutput())
    DrawText(0,0,"SCORE : "+Str(SCORE),$0000FF,$0)
    DrawText(150,0,"LIFE : "+Str(LIFE),$0000FF,$0)
    DrawText(650, 0, "ESCAPE to EXIT",$ffffff, $0):StopDrawing():SX(10)-1
    If sx(10) < -160:sx(10)=1500:sy(10)=r(460,140):EndIf:ElseIf GO=1:StopSound(23)
    PS=0:StartDrawing(ScreenOutput()):DrawingFont(f):TG$="GAME OVER"
    DrawText( R(400,398)-TextWidth(TG$)/2,R(280,278),tg$,$FFFFFF,$0)
    DrawingFont(f1)
    DrawText(R(250,248),R(510,508),"Press LMB to restart",$FFFFFF,$0)
    DrawText(R(290,288),R(120,118),"SCORE : "+Str(score),$FFFFFF,$0):StopDrawing()
    If MouseButton(#PB_MouseButton_Left):score=0:Life=3:x=5:sx(1)=x:PS=1:GO=0
    EndIf:EndIf:FlipBuffers():deltatime=(ElapsedMilliseconds()-StartTime)/1000
    Until KeyboardPushed(#PB_Key_Escape)

Unpunched Code :
Code: [Select]
;*****************************************************************************
;*
;* Birthday Punch : PureBasic 15 years of happiness
;* PureBasic 5.31 x86
;* 192 lines of 80 chars of code or data as you want
;*
;* Name     : PB vs THE WORLD
;* Author   : Ar-S - Music made with Music Maker Jam
;* Date     : Nov/Oct 2015
;* Notes    : Dedicated To my mom Apr 1940 - Sept 2015
;*
MessageRequester("Info","Use Arrows to move, space to shoot and left ctrl to use shield"+Chr(10)+"Left Mouse Button to restart"+Chr(10)+Chr(10)+"Fleches pour se diriger, ctrl : bouclier, Espace:Feu, Bouton de gauche souris pour recommencer",#PB_MessageRequester_Ok) ; LIGNE NON PRIS EN COMPTE
     
UseOGGSoundDecoder()

Macro m:Macro:EndMacro
m dec:decoder():EndMacro
m e:examine:EndMacro
m s(n,l,h,x,y):EndMacro
m _s:Structure:EndMacro


InitSprite():InitKeyboard():InitMouse():UseOGGSound#dec:UsePNGImage#dec
InitSound()

_S BB
x.i
y.i
ID.b
End#_S

_S SP
x.i
y.i
n.i
LL.i
HH.i
v.b
r.f
End#_S

_S St
x.i
y.i
v.b
n.b
End#_S

_S SN
D.i
F.i
End#_S

M R:random:EndMacro

M P(S)
PlaySound(S,#PB_Sound_MultiChannel,70)
EndMacro

M PP(S)
PlaySound(S,#PB_Sound_Loop,80)
EndMacro

m _k(k)
KeyboardPushed(k)
EndMacro

M G(z):Global.Z:EndMacro

M CS(n,x,y,l,h)
ClipSprite(n,x,y,l,h)
sp(n)\LL=l/2
sp(n)\HH=h/2
ZoomSprite(n,l/2,h/2)
v(n)
EndMacro

m v(n)
sp(n)\v = R(6,2)
EndMacro

m SX(n)
sp(n)\x
EndMacro

m SY(n)
sp(n)\y
EndMacro

M Redo(n)
SX(n)=820
SY(n) = R(500,100)
v(n)
EndMacro

m EX(n)
St(n)\x
EndMacro

m EY(n)
St(n)\y
EndMacro

m EN(Z)
St(Z)\n
EndMacro

m EV(n)
St(n)\v
EndMacro

m _r(n,d)
SpriteQuality(1)
RotateSprite(n,d,#PB_Absolute)
EndMacro

Global NewList BB.BB()
Global F=LoadFont(16, "Arial", R(80,50))
Global F1=LoadFont(17, "Arial", 24)

Global.b feu,NF,ENNEMI,VIZ,ShotOn.b=#True
Global.i x,y,xi,T
Global SCORE,LIFE
Global Dim sp.SP(16)
Global Dim st.st(100)
Global TimeElapset=ElapsedMilliseconds()

LoadSound(20,"01.ogg") ; laser
LoadSound(21,"02.ogg") ; impact
LoadSound(22,"03.ogg") ; shield
LoadSound(23,"04.ogg") ; shield

SCORE = 0
LIFe = 3
x= 150
y = 350
NF = 9 ; numero du sprite PB en cours
xi = 2500

t1$ = "PURE BASIC VS THE WORLD !"
t2$ = "HAPPY PURE BIRTHDAY"



; Positionnement des étoiles dans tableau
For i   = 0 To 100
  EX(i) = R(820)
  EY(i) = R(600)
Next

For i = 0 To 20
  EN(i) = 13
  EV(i) = 3
Next


For i = 21 To 60
  EN(i) = 14
  EV(i) = 6
Next

For i = 61 To 100
  EN(i) = 15
  EV(i) = 10
Next



OpenScreen(800,600,32,"", #PB_Screen_SmartSynchronization)
LoadSprite(0,"im.png",8|4)

For i = 1 To 15
  CopySprite(0,i,8|4)
Next


CS(1,7,142,232,133) ; ship D
CS(2,289,135,234,139) ; SHIELD


CS(3,0,1,129,128) ; Logo PYTHON
CS(4,129,1,128,128) ; Logo RUBY
CS(5,257,0,118,130) ; Logo C#
CS(6,379,0,101,131) ; Logo JAVA
CS(7,478,1,115,130) ; Logo JavaScript
CS(8,595,8,250,126) ; Logo VB
CS(9,533,213,53,62) ; PB LOGO
ClipSprite(10,675,138,140,136) ; PLanete
CS(11,606,231,25,43)           ; Big reac
CS(12,631,231,25,43)           ; Smal reac

CS(13,840,266,8,8) ; big etoile
CS(14,833,270,6,5) ; med etoile
CS(15,824,271,3,3) ; sm etoile

FreeSprite(0)

txt.s = t1$
xtx = r(500,100)
ColT = RGB(R(255),R(255),R(255))
sx(10) = 1500
sy(10) = r(460,140)



PS = 1

Repeat
 
  ; Chrono
  StartTime.i = ElapsedMilliseconds()
 
  ClearScreen(0)
  E#Mouse()
  E#Keyboard()
 
  ; TEMPORISATION DES TIRS --------------
  If ElapsedMilliseconds()-TimeElapset>=350
    ShotOn=#True
    TimeElapset=ElapsedMilliseconds()
  EndIf
  ; -------------------------------------
 
 
  If GO = 0
    If PS = 1
      PP(23)
      ps+1
    EndIf
   
    For i = 0 To 100
      DisplayTransparentSprite(Random(15,13), EX(i), EY(i),255)
      EX(i) - EV(i)
     
      If EX(i) < 0
        EX(i) = 805 : ey(i) = R(600)
      EndIf
    Next
   
    DisplayTransparentSprite(10, SX(10), SY(10),255)  ; Planete
   
    ; GESTION DU SCROLL TEXT
    StartDrawing(ScreenOutput())
   
    DrawingFont(f)
    DrawingMode(#PB_2DDrawing_Transparent )
   
    If xi < -2500
      NT+1
     
      If NT<2
        txt.s = t1$
      ElseIf NT = 2
        txt.s = t2$
      Else
        NT=0
      EndIf
     
      xi = 2500
      xtx = r(500,100)
      ColT = RGB(R(255),R(255),R(255))
    EndIf
   
    DrawText(xi, xtx,txt.s ,ColT, $0)
   
    StopDrawing()
    ; ////
   
   
    Xi-6
   
   
    ; Position Vaisseau et Vaisseau shield
    sx(2) = sx(1)
    sy(2) = sy(1)
   
    ; Affichage des logos ennemis
    For S = 3 To 8
      DisplayTransparentSprite(S, SX(S), SY(S),255)
    Next
   
   
    ;-----------------------------------------
   
    ; DIRECTION VAISSEAU avec diagonales
   
    ;-----------------------------------------
   
    If _K(#PB_Key_Up)
      y-5
      ViZ = 1
     
      If _K(#PB_Key_Left)
        x-5
        ViZ = 0
      ElseIf _K(#PB_Key_Right)
        X+5
        ViZ = 1
      EndIf
     
     
    ElseIf _K(#PB_Key_Down)
      y+5
      ViZ = 1
      If _K(#PB_Key_Left)
        x-5
        ViZ = 0
      ElseIf _K(#PB_Key_Right)
        X+5
        ViZ = 1
      EndIf
     
     
    ElseIf _K(#PB_Key_Left)
      x-5
      VIZ = 0
     
    ElseIf _K(#PB_Key_Right)
      SX(1)=x
      x+5
      ViZ = 1
    EndIf
   
    If y < 25
      y=25
    ElseIf y > 530
      y = 530
    EndIf
    If x < 0
      x = 0
    ElseIf x > 700
      x = 700
    EndIf
   
    ; Vaisseau
    SX(1)=x
    Sy(1)=y
    ; Reacteurs
    Sx(11)=x-10
    Sy(11)=y+23
    Sx(12)=Sx(11)
    Sy(12)=Sy(11)
   
    ;-----------------------------------------
   
    ;-----------------------------------------
    ; TIRS si ESPACE
    ;-----------------------------------------

    If _k(#PB_Key_Space) And ShotOn
     
      AddElement(BB())
      BB()\X=SX(1)+120
      BB()\Y=SY(1)+15
      BB()\ID = 9 ; logo PBbullet
      Debug "NbrBalle : " + ListSize(BB())
      ShotOn=#False
     
      ;feu = 2
      P(20)
    EndIf
   
    ;-----------------------------------------
    ; BOUCLIER si CTRL
    ;-----------------------------------------
   
    If _K(#PB_Key_LeftControl)
      shield = 1
      P(22)
    Else
      shield = 0
    EndIf
   
    If shield = 0
      ship = 1
    Else
      ship = 2
    EndIf
   
    ;-----------------------------------------
    ; AFFICHAGE
    ;-----------------------------------------
    ; Sprite vaiseau + reacteurs
    DisplayTransparentSprite(ship, x, y, 255)
    RE = R(12,11)
    DisplayTransparentSprite(RE, sx(RE), Sy(RE),200)
   
    ; Tirs logos PB et Collisions
    ;     If feu = 2
    ForEach BB()
      BB()\X + 6
      DisplayTransparentSprite(BB()\ID, BB()\X, BB()\Y,255)
    Next     
    ; TESTS DES COLLISIONS AVEC LOGO PB
    For ENNEMI = 3 To 8
      ForEach BB()       
        If SpriteCollision(9, BB()\X, BB()\Y, ENNEMI, sx(ENNEMI), sy(ENNEMI) ) <> 0
          T = ENNEMI
          SCORE+1
          redo(ENNEMI)
          If ListSize(BB()) > 0
            DeleteElement (BB())
          EndIf
          ;           feu = 0
          P(21)
        EndIf
      Next
    Next
   
   
    If ListSize(BB()) > 0 And BB()\X > 810
      DeleteElement (BB()) ;sx(9) = x+130
    EndIf
   
   
   
   
    ;     EndIf
   
   
    ; DEFILEMENT DES ENNEMIS
    For i = 3 To 8
      SX(i) - sp(i)\v
      SpriteQuality(1)
      RotateSprite(i, ROT.f,#PB_Absolute)
      ROT.f-0.5
      If SX(i)< -100
        redo(i)
      EndIf
    Next
   
    ; TESTS DES COLLISIONS AVEC ship
    For COL = 3 To 8
      If SpriteCollision(1, sx(1), sy(1), COL, sx(col), sy(col) ) <> 0
        If shield = 1
          score-1
          If Score <= 0
            Score = 0
          EndIf
         
        ElseIf shield = 0
          life-1
          If Life <= 0
            GO = 1
          EndIf
        EndIf
        P(21)
        redo(col)
       
      EndIf
    Next
   
   
   
   
   
   
   
    ;Affichage  texte
    StartDrawing(ScreenOutput())
    DrawText(0, 0, "SCORE : " + Str(SCORE),$0000FF, $0)
    DrawText(150, 0, "LIFE : " + Str(LIFE),$0000FF, $0)
    DrawText(650, 0, "ESCAPE to EXIT",$ffffff, $0)
   
    StopDrawing()
   
    SX(10) -1
    If sx(10) < -160
      sx(10) = 1500
      sy(10) = r(460,140)
    EndIf
   
   
   
  ElseIf GO = 1 ; Si GAME OVER
   
    StopSound(23)
    PS = 0
    ;Affichage Texte
    StartDrawing(ScreenOutput())
    DrawingFont(f)
    TG$ = "GAME OVER "
    DrawText( R(400,398) - TextWidth(TG$)/2 , R(280,278), tg$, $FFFFFF, $0)
    DrawingFont(f1)
    DrawText(R(250,248), R(510,508), "Press LMB to restart", $FFFFFF, $0)
    DrawText(R(290,288), R(120,118), "SCORE : "+Str(score), $FFFFFF, $0)
    StopDrawing()
   
    If MouseButton(#PB_MouseButton_Left)
      score = 0
      Life = 3
      x = 5 : sx(1) = x
      PS = 1
      GO=0
     
    EndIf
   
  EndIf
 
  FlipBuffers()
 
  deltatime = (ElapsedMilliseconds() - StartTime) / 1000
 
 
Until KeyboardPushed(#PB_Key_Escape)

43
Nice remake, thanks for sharing.
I add emook's mod with succes. :goodpost:

44
General chat / Re: The Welcoming Committee
« on: October 15, 2015 »
Hi dudes,

I'm Ar-S, i loved the old demoscene (redsector, budbrain etc..) especially on Amiga (the best computer ever).
I used to make some protracker a long time ago. Some years ago, i started to code in PureBasic on my PC (no more amiga, it's dead). I'm happy to find you. I'm from France so excuse by advance my poor english.
I'm glad to be here  :cheers:

Pages: 1 2 [3]