Author Topic: Como evitar que um cronômetro interfira numa cena?  (Read 530 times)

lb fan

  • Newbie
  • *
  • Posts: 5
    • View Profile
Como evitar que um cronômetro interfira numa cena?
« on: May 06, 2018, 07:16:49 AM »
Olá, tentei colocar um cronômetro no jogo another dimension mas ele trava a cena e eu não consigo movimentar o personagem.

Minha intenção é fazer com que o personagem tenha que completar uma tarefa em um determinado tempo, segue o código. até mais..


Var Counter Integer, CounterLin Integer, CounterCol Integer, JetHeight Integer, JetWidth Integer
Var PcHeight Integer, PcWidth Integer, PCLin Integer, PcCol Integer
Var Direction String, LinMan Integer, ColMan Integer, KeyLeft String, KeyRight String
Var IsWalking Integer, Temp Integer, ColJaguar Integer, LinJaguar Integer, StartJaguar Integer     

Var cron Integer  ''''''''''
cron = 0          ''''''''''



Window Size=48,Max, Res=750,1280, Pos=Center,Center, Border=False



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' aqui''''''''''''''''''''''
Label Test, " informações de tempo ", 10, 700, 25, 100   
Label Test.FontName = "Arial"; Label Test.FontSize = 8 
Label Test.BackColor = Yellow; Label Test.Alignment = 0
 

Label Test2, "", 10, 802, 25, 20   
Label Test.FontName = "Arial"; Label Test.FontSize = 8 
Label Test.BackColor = Yellow; Label Test.Alignment = 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Window Background="Background04.jpg"

Sound Atmosphere01, "Atmosphere01.mp3"
Sound Atmosphere01.Loop = True
Sound Atmosphere01.Play

Sound Roar, "Roar.mp3"

AnimatedGif LeftTurn, "LeftTurn.gif"
AnimatedGif RightTurn, "RightTurn.gif"
AnimatedGif WalkingLeft, "WalkingLeft.gif"
AnimatedGif WalkingRight, "WalkingRight.gif"
AnimatedGif Block, "Block.gif"
AnimatedGif Block.Lin = 392; AnimatedGif Block.Col = 785
AnimatedGif Block.Visible = True

AnimatedGif Fire01, "Fire01.gif"
AnimatedGif Fire01.Lin = 430
AnimatedGif Fire01.Col = 430
AnimatedGif Fire01.Visible = True
AnimatedGif Fire01.Play

AnimatedGif Fire02, "Fire02.gif"
AnimatedGif Fire02.Lin = 615
AnimatedGif Fire02.Col = 680
AnimatedGif Fire02.Visible = True
AnimatedGif Fire02.Play

ColJaguar = 1500; LinJaguar = 450
AnimatedGif Jaguar, "Jaguar.gif"
AnimatedGif Jaguar.Lin = LinJaguar
AnimatedGif Jaguar.Col = ColJaguar
AnimatedGif Jaguar.Back
AnimatedGif Jaguar.Visible = True
AnimatedGif Jaguar.Play

LinMan = 460; ColMan = 600
AnimatedGif LeftTurn.Lin = LinMan; AnimatedGif LeftTurn.Col = ColMan
AnimatedGif RightTurn.Lin = LinMan; AnimatedGif RightTurn.Col = ColMan
AnimatedGif LeftTurn.Visible = True
Direction = "RIGHT": IsWalking = 0

While 1 = 1
  cronometro() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''aqui'''''''''''''''''''''
  If StartJaguar = 0
    KeyRight = KeyTest("39")
    KeyLeft = KeyTest("37")
    If KeyRight = "39+"
      WalkRight()
     ' cronometro()
    EndIf
    If KeyLeft = "37+"
      WalkLeft()
     ' cronometro()
    EndIf
    If KeyRight = "39-" Or KeyLeft = "37-"
      If IsWalking = 1; Temp++; EndIf
      If Temp = 5; StopMan(); EndIf
     ' cronometro()
    EndIf

    If ColMan < 450 And ColMan > 220 And Direction = "LEFT"; LinMan++; EndIf
    If ColMan >= 220 And ColMan < 450 And Direction = "RIGHT"; LinMan--; EndIf

    If ColMan > 900
      If StartJaguar = 0
        Sound Roar.Play
        StartJaguar = 1
      EndIf 
    EndIf
  Else
    AnimatedGif Jaguar.Col = ColJaguar
    AnimatedGif Jaguar.Lin = LinJaguar
    ColJaguar-=9
    If ColJaguar < 450 And ColJaguar > 220; LinJaguar+=2; EndIf   
  EndIf
   
  Wait Events, 350
Loop

EndProgram

Sub StopMan()
If IsWalking = 1
  If Direction = "LEFT"
    AnimatedGif RightTurn.Lin = LinMan; AnimatedGif RightTurn.Col = ColMan
    AnimatedGif LeftTurn.Visible = False
    AnimatedGif WalkingLeft.Visible = False
    AnimatedGif WalkingRight.Visible = False
    AnimatedGif RightTurn.FrameNumber, 0
    AnimatedGif RightTurn.Visible = True
  Else
    AnimatedGif LeftTurn.Lin = LinMan; AnimatedGif LeftTurn.Col = ColMan
    AnimatedGif RightTurn.Visible = False
    AnimatedGif WalkingLeft.Visible = False
    AnimatedGif WalkingRight.Visible = False
    AnimatedGif LeftTurn.FrameNumber, 0
    AnimatedGif LeftTurn.Visible = True
  EndIf
  IsWalking = 0
EndIf
EndSub

Sub WalkRight()
AnimatedGif WalkingRight.Lin = LinMan; AnimatedGif WalkingRight.Col = ColMan
AnimatedGif LeftTurn.Visible = False
AnimatedGif RightTurn.Visible = False
AnimatedGif WalkingLeft.Visible = False
AnimatedGif WalkingRight.Visible = True
AnimatedGif WalkingRight.NextFrame
ColMan += 5
Direction = "RIGHT"; IsWalking = 1; Temp = 0
EndSub

Sub WalkLeft()
AnimatedGif WalkingLeft.Lin = LinMan; AnimatedGif WalkingLeft.Col = ColMan
AnimatedGif LeftTurn.Visible = False
AnimatedGif RightTurn.Visible = False
AnimatedGif WalkingRight.Visible = False
AnimatedGif WalkingLeft.Visible = True
AnimatedGif WalkingLeft.NextFrame
ColMan -= 5
Direction = "LEFT"; IsWalking = 1; Temp = 0
EndSub
 
''''''''''''' aqui''''''''''''
Sub cronometro()

While cron < 360
Label Test2.Txt=cron

cron++                                 
Wait 1 


Loop
 
EndSub
   
''''''''''''' '''''''''''''''     
« Last Edit: May 11, 2018, 07:51:26 AM by lb fan »

Daniel

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Como evitar que um cronômetro interfira numa cena?
« Reply #1 on: May 11, 2018, 05:33:21 AM »
Cole o código com as alterações aqui. Aí podemos analisar onde está o erro.

eleusmario

  • Administrator
  • Newbie
  • *****
  • Posts: 19
    • View Profile
Re: Como evitar que um cronômetro interfira numa cena?
« Reply #2 on: May 19, 2018, 07:42:43 AM »
Hi Daniel!

In this case you should create a timer, below the corrected code:

Code: [Select]
Var Counter Integer, CounterLin Integer, CounterCol Integer, JetHeight Integer, JetWidth Integer
Var PcHeight Integer, PcWidth Integer, PCLin Integer, PcCol Integer
Var Direction String, LinMan Integer, ColMan Integer, KeyLeft String, KeyRight String
Var IsWalking Integer, Temp Integer, ColJaguar Integer, LinJaguar Integer, StartJaguar Integer     

Var cron Integer  ''''''''''
cron = 0          ''''''''''



Window Size=48,Max, Res=750,1280, Pos=Center,Center, Border=False



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' aqui''''''''''''''''''''''
Label Test, " informações de tempo ", 10, 700, 25, 100   
Label Test.FontName = "Arial"; Label Test.FontSize = 8
Label Test.BackColor = Yellow; Label Test.Alignment = 0
 

Label Test2, "", 10, 802, 25, 20   
Label Test.FontName = "Arial"; Label Test.FontSize = 8
Label Test.BackColor = Yellow; Label Test.Alignment = 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Timer Cronometro.Off
Timer Cronometro.Activate, 10

Window Background="Background04.jpg"

Sound Atmosphere01, "Atmosphere01.mp3"
Sound Atmosphere01.Loop = True
Sound Atmosphere01.Play

Sound Roar, "Roar.mp3"

AnimatedGif LeftTurn, "LeftTurn.gif"
AnimatedGif RightTurn, "RightTurn.gif"
AnimatedGif WalkingLeft, "WalkingLeft.gif"
AnimatedGif WalkingRight, "WalkingRight.gif"
AnimatedGif Block, "Block.gif"
AnimatedGif Block.Lin = 392; AnimatedGif Block.Col = 785
AnimatedGif Block.Visible = True

AnimatedGif Fire01, "Fire01.gif"
AnimatedGif Fire01.Lin = 430
AnimatedGif Fire01.Col = 430
AnimatedGif Fire01.Visible = True
AnimatedGif Fire01.Play

AnimatedGif Fire02, "Fire02.gif"
AnimatedGif Fire02.Lin = 615
AnimatedGif Fire02.Col = 680
AnimatedGif Fire02.Visible = True
AnimatedGif Fire02.Play

ColJaguar = 1500; LinJaguar = 450
AnimatedGif Jaguar, "Jaguar.gif"
AnimatedGif Jaguar.Lin = LinJaguar
AnimatedGif Jaguar.Col = ColJaguar
AnimatedGif Jaguar.Back
AnimatedGif Jaguar.Visible = True
AnimatedGif Jaguar.Play

LinMan = 460; ColMan = 600
AnimatedGif LeftTurn.Lin = LinMan; AnimatedGif LeftTurn.Col = ColMan
AnimatedGif RightTurn.Lin = LinMan; AnimatedGif RightTurn.Col = ColMan
AnimatedGif LeftTurn.Visible = True
Direction = "RIGHT": IsWalking = 0

While 1 = 1
  If StartJaguar = 0
    KeyRight = KeyTest("39")
    KeyLeft = KeyTest("37")
    If KeyRight = "39+"
      WalkRight()
    EndIf
    If KeyLeft = "37+"
      WalkLeft()
    EndIf
    If KeyRight = "39-" Or KeyLeft = "37-"
      If IsWalking = 1; Temp++; EndIf
      If Temp = 5; StopMan(); EndIf
    EndIf

    If ColMan < 450 And ColMan > 220 And Direction = "LEFT"; LinMan++; EndIf
    If ColMan >= 220 And ColMan < 450 And Direction = "RIGHT"; LinMan--; EndIf

    If ColMan > 900
      If StartJaguar = 0
        Sound Roar.Play
        StartJaguar = 1
      EndIf
    EndIf
  Else
    AnimatedGif Jaguar.Col = ColJaguar
    AnimatedGif Jaguar.Lin = LinJaguar
    ColJaguar-=9
    If ColJaguar < 450 And ColJaguar > 220; LinJaguar+=2; EndIf   
  EndIf
   
  Wait Events, 350
Loop

EndProgram

Sub StopMan()
If IsWalking = 1
  If Direction = "LEFT"
    AnimatedGif RightTurn.Lin = LinMan; AnimatedGif RightTurn.Col = ColMan
    AnimatedGif LeftTurn.Visible = False
    AnimatedGif WalkingLeft.Visible = False
    AnimatedGif WalkingRight.Visible = False
    AnimatedGif RightTurn.FrameNumber, 0
    AnimatedGif RightTurn.Visible = True
  Else
    AnimatedGif LeftTurn.Lin = LinMan; AnimatedGif LeftTurn.Col = ColMan
    AnimatedGif RightTurn.Visible = False
    AnimatedGif WalkingLeft.Visible = False
    AnimatedGif WalkingRight.Visible = False
    AnimatedGif LeftTurn.FrameNumber, 0
    AnimatedGif LeftTurn.Visible = True
  EndIf
  IsWalking = 0
EndIf
EndSub

Sub WalkRight()
AnimatedGif WalkingRight.Lin = LinMan; AnimatedGif WalkingRight.Col = ColMan
AnimatedGif LeftTurn.Visible = False
AnimatedGif RightTurn.Visible = False
AnimatedGif WalkingLeft.Visible = False
AnimatedGif WalkingRight.Visible = True
AnimatedGif WalkingRight.NextFrame
ColMan += 5
Direction = "RIGHT"; IsWalking = 1; Temp = 0
EndSub

Sub WalkLeft()
AnimatedGif WalkingLeft.Lin = LinMan; AnimatedGif WalkingLeft.Col = ColMan
AnimatedGif LeftTurn.Visible = False
AnimatedGif RightTurn.Visible = False
AnimatedGif WalkingRight.Visible = False
AnimatedGif WalkingLeft.Visible = True
AnimatedGif WalkingLeft.NextFrame
ColMan -= 5
Direction = "LEFT"; IsWalking = 1; Temp = 0
EndSub

''''''''''''' aqui''''''''''''
Sub Timer_cronometro(1)
  Label Test2.Txt=cron
  cron++                                 
EndSub
   

lb fan

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Como evitar que um cronômetro interfira numa cena?
« Reply #3 on: May 21, 2018, 05:08:11 AM »
muito obrigado senhor eleusmario por ter sanado minha duvida.
até mais ...

eleusmario

  • Administrator
  • Newbie
  • *****
  • Posts: 19
    • View Profile
Re: Como evitar que um cronômetro interfira numa cena?
« Reply #4 on: May 21, 2018, 05:38:15 AM »
Alternatively you can assign the value inside the loop instead of creating a timer, I think it gets better:

Code: [Select]
While 1 = 1
  If StartJaguar = 0
    KeyRight = KeyTest("39")
    KeyLeft = KeyTest("37")
    If KeyRight = "39+"
      WalkRight()
    EndIf
    If KeyLeft = "37+"
      WalkLeft()
    EndIf
    If KeyRight = "39-" Or KeyLeft = "37-"
      If IsWalking = 1; Temp++; EndIf
      If Temp = 5; StopMan(); EndIf
    EndIf

    If ColMan < 450 And ColMan > 220 And Direction = "LEFT"; LinMan++; EndIf
    If ColMan >= 220 And ColMan < 450 And Direction = "RIGHT"; LinMan--; EndIf

    If ColMan > 900
      If StartJaguar = 0
        Sound Roar.Play
        StartJaguar = 1
      EndIf
    EndIf
  Else
    AnimatedGif Jaguar.Col = ColJaguar
    AnimatedGif Jaguar.Lin = LinJaguar
    ColJaguar-=9
    If ColJaguar < 450 And ColJaguar > 220; LinJaguar+=2; EndIf   
  EndIf
   
  Label Test2.Txt=cron
  cron++                                 

  Wait Events, 350
Loop

lb fan

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Como evitar que um cronômetro interfira numa cena?
« Reply #5 on: May 21, 2018, 06:50:11 AM »
mais uma vez obrigado. alguma novidade sobre o biblia do logic basic?