News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

How to change the fase/level?

Started by iloveTALLwoman, January 09, 2008, 04:57:05 PM

Previous topic - Next topic

iloveTALLwoman

Hello :)
I'm sorry for this stupid question
I'm a not profissional coder. I code just for fun

I have studing the codes exemples, but I dont know how I change in my game to a next level/fase.
The game is very simple: A mouse controled ball when colide whit sprites the sprites are gone.
This game is copy of parts of exemples Help


Main.pba
Fase2.pba (The intire code I put in a function)
Fase3.pba
Fase4.pba

I try to do in line 145:

If ThisSprite <1
fase2()
EndIf

I try anhoter commands but unsuccessfull

Thank you very much for any Help ;P

Here are the code Main.pba (Fase1)
1 ; PROJECT : Joguinho colisao
    2 ; AUTHOR  : Ser Supremo
    3 ; CREATED : 6/1/2008
    4 ; EDITED  : 9/1/2008
    5 ; ---------------------------------------------------------------------
    6
    7 ; ---------------------------------------------------------------------
    8
    9
   10 ; ==============================
   11 ; Set the Default Screens TITLE
   12 ; ==============================
   13
   14 TitleScreen "Joguinho - Elimine todas as bolinhas"
   15
   16 ;Mouse off
   17 Mouse Off
   18
   19 ; Show the Intro page
   20 ShowIntro()
   21
   22 ; Load the "Ariel" font as font 2, size 24, in the normal style
   23   LoadFont "Ariel",2,24,0
   24   
   25 ; Set Font 2 at the current font.
   26   SetFont 2
   27   
   28
   29 ; ========================
   30 ; Part 1 - Create images
   31 ; ========================
   32 ; Load Image
   33 LoadImage CurrentDir$()+"bubble_64x64.bmp",2
   34 LoadImage CurrentDir$()+"HarmTile160.jpg",3
   35 LoadImage CurrentDir$()+"roseclep.bmp",1
   36
   37 ; Load the music
   38    MyMusic=LoadNewMusic("djsammy_boysofsummer_clubmix.it")
   39   
   40 ; Activate Looping for this music channel
   41 LoopMusic MyMusic,True
   42
   43 ;  Play the Music
   44    PlayMusic MyMusic
   45
   46 ; =============================
   47 ; Part 2- Create some sprites
   48 ; =============================
   49
   50
   51
   52 ; Create Sprite 1, and assign it image 1
   53   CreateSprite 1 
   54   SpriteImage 1,1
   55   CenterSpriteHandle 1
   56 ; Enable Collision for Sprite #1
   57   SpriteCollision 1,On
   58 ; Set Sprite #1 to collision Class %0001
   59   SpriteCollisionClass 1,%0001
   60   
   61 ; Create a bunch fo sprites to check collision against
   62   
   63    starsN=100
   64   
   65   Type Bubble
   66 x#,y#,XSpeed#,Yspeed#,Angle#,RotSpeed#
   67   EndType
   68
   69
   70   Dim Stars(StarsN) As Bubble
   71   
   72   Sw=GetScreenWidth()-64
   73   Sh=GetScreenHeight()-64
   74   
   75   For starsI=1 To starsN
   76 stars(starsI).x = Rnd(sw)
   77 stars(starsI).y = Rnd(sh)
   78 stars(starsI).xspeed = RndRange#(1,4)
   79 stars(starsI).yspeed = RndRange#(1,4)
   80
   81 CreateSprite starsI
   82 SpriteImage starsI,2
   83 PositionSprite starsI,starsX,starxY 
   84
   85    ; Enable Collision for this sprite
   86     SpriteCollision starsI,On
   87    ; Set sprite to Collision Class %0010
   88     SpriteCollisionClass starsI,%0010
   89   
   90   Next starsI
   91
   92
   93
   94 ; =============================
   95 ; Part 3- The Main Loop
   96 ; =============================
   97
   98 ; Start a DO/Loop
   99 Do
  100   ; Clear the screen
  101 Cls 0
  102
  103   ; Tile and Animate the background
  104 TileImage 3,x,0,0
  105 inc x
  106
  107   ; Display a message
  108     Print "Hit Sprites to Hide Them"
  109     Print "Press Space to Show ALL sprites"
  110     
  111   ; Animate the sprite
  112 For starsI=1 To starsN
  113 x#=stars(starsI).x+stars(starsI).xspeed
  114 Y#=stars(starsI).y+stars(starsI).Yspeed
  115
  116 If X#<0 Or X#>Sw  Then stars(starsI).xspeed=stars(starsI).xspeed*-1
  117 If Y#<0 Or Y#>Sh  Then stars(starsI).yspeed=stars(starsI).yspeed*-1
  118
  119 PositionSprite starsI,x#,y#
  120
  121 stars(starsI).x=x#
  122 stars(starsI).Y=y#
  123
  124       Next starsI
  125
  126     
  127   ; Position the Sprite 1 at the mouses position
  128     SpriteImage 1,1
  129     CenterSpriteHandle 1
  130     PositionSprite 1,MouseX(),MouseY()
  131
  132   ; Check if sprite #1 hit another sprite
  133     ThisSprite=SpriteHit(1,GetFirstSprite(),%0010)
  134   
  135   ; If there was an impact, then we loop through and
  136   ; find any other sprites we might have hit also
  137     While ThisSprite>0
  138         Print "Hide Sprite:"+Str$(ThisSprite)
  139        ; Hide the sprite
  140         SpriteVisible thisSprite,False
  141       ; Check if this sprite hit another sprite ?   
  142         NextSprite=GetNextSprite(ThisSprite)
  143         ThisSprite=SpriteHit(1,NextSprite,%0010)
  144         
  145       
  146         
  147     EndWhile   
  148     
  149     
  150     ; Check if the SpaceKey is pressed    
  151     If SpaceKey()=True
  152       ThisSprite=GetFirstSprite()
  153       While ThisSprite>0
  154         SpriteVisible ThisSprite,True             
  155         ThisSprite=GetNextSprite(ThisSprite)
  156       EndWhile
  157     EndIf
  158
  159       
  160    ; Draw All of the sprites
  161     DrawAllSprites
  162
  163 ; Draw the screen
  164   Sync
  165 ; Loop back to the DO statement
  166 Loop
  167
  168 Function ShowIntro()
  169
  170 MyMusic=LoadNewMusic("LevUp.xm")
  171   
  172   ; Activate Looping for this music channel
  173 LoopMusic MyMusic,false
  174
  175  ;  Play the Music
  176    PlayMusic MyMusic
  177
  178
  179
  180 Title=LoadNewImage("splash_personal.jpg")
  181 PrepareFXimage Title
  182
  183 FadeRate#=1000/255
  184 FadeLevel=255
  185
  186 Spr=newSprite(400,300,Title)
  187 CenterSPritehandle spr
  188 SpriteDrawmode Spr, 2+2048
  189
  190 Level#=0.95
  191
  192 SpriteAlphaLevel spr,Level#
  193 SpriteAlphaCOlour spr,rgb(0,0,0)
  194
  195 IntroEndTime=timer()+5000
  196
  197 ;BackDropColour=RGB(112,167,222)
  198 ;CurrentColour=BackDropColour
  199
  200
  201 repeat
  202 Time=timer()
  203
  204 if fade=false
  205 if Spacekey() or time>IntroEndTime
  206 fade=true
  207 FadeStartTime =timer()
  208 FadeENDTime =FadeStartTime+1000
  209 endif
  210 endif
  211
  212 ; Check if fade out is active
  213 if Fade=true
  214 Level#=(Time-FadeStartTime)/1000.0
  215 Level#=1-Level#
  216 if Level#<0 then Level#=0
  217 if Level#>0.95 then Level#=0.95
  218 endif
  219
  220
  221 SpriteAlphaLevel Spr,Level#
  222 CurrentColour=RgbAlphaBlend(0,BackDropColour,Level#*100)
  223
  224
  225 Cls CurrentColour
  226 drawallsprites
  227 Sync
  228 Until Fade=true and time>FadeEndTime
  229
  230 DeleteSprite Spr
  231 DeleteImage Title
  232
  233
  234 EndFunction

blackmeadow

what are you trying to do?  reset the game after the bubbles are gone?

iloveTALLwoman

Yes.... :)

Reset the game and go to next level/fase

Silvh

You will have to create a level system for that, With a simple Math function which will tell you how much harder the level will be. This is not a single line of code or a simple example. A game must be BUILD to use levels, not just adding one function to do so.
"All we have to do, is decide what to do. With the code that is given to us"

iloveTALLwoman


Adaz

Hi iloveTALLwoman,
hmm...what's the name of that windows-theme you're using? :)
thanks!


Ádáz

Hungary

iloveTALLwoman

Hi Adaz

This window-theme name is "PlasticTube" from StyleXP software
- http://www.tgtsoft.com/