Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Game with turns

    Beginners
    help turns
    3
    11
    944
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PickleCatStars
      PickleCatStars F last edited by

      There’s functions in fuze that keep track of time, so all that stuff is definitely possible :)

      1 Reply Last reply Reply Quote 1
      • landein207
        landein207 last edited by

        That means i need to check what functions track the time but thanks i didn't knew that

        waldron 1 Reply Last reply Reply Quote 1
        • waldron
          waldron F @landein207 last edited by

          @landein207 this is something I'm starting to grasp probably best to test in a test program before dealing with an entire page of code.and before trying to deal with multiple actions start small and add to it in chunks. Timers and counters if's and else's

          1 Reply Last reply Reply Quote 1
          • PickleCatStars
            PickleCatStars F last edited by PickleCatStars

            Yep. Just make a program using print()s first, that says PLAYER TURN PRESS X or whatever, and waits for a button press, then says ENEMY TURN and has a countdown on screen, then loops back to the start.

            Sounds simple, but there’s a surprising amount of stuff there to get to grips with if you’re just getting into things. One tip I can give is do not use sleep() - that literally locks your program so it can’t do anythine else while it’s waiting. Use the time() command instead and compare the current time to the time you started or the time you want it to end. That way you can do other stuff inbetween :)

            1 Reply Last reply Reply Quote 3
            • landein207
              landein207 last edited by

              ok @waldron and @toxibunny i will try what you two sugest if i can't make it properly i will ask here for help with that, thanks

              1 Reply Last reply Reply Quote 2
              • landein207
                landein207 last edited by

                Ok i have been trying do the turns with time() but im kinda like how can i compare the time the turn ends and the player turn so now im in timers and it amoust works but i need to find out how can i reset the timer so how can i reset the timer (or if reseting timers isn't possible how can i compare the time the enemy turn ends/pauses time() and the player turn starts)

                1 Reply Last reply Reply Quote 1
                • PickleCatStars
                  PickleCatStars F last edited by

                  you don’t really need to compare the enemy turn end time to the player turn start time - the player turn starts when the enemy turn ends, no matter what time it is. Here’s a (pseudocode) example of the sort of thing I mean.

                  Gameisrunning = true
                  
                  While gameisrunning loop //main loop
                      Currenttime = time()
                      Enemyturnstarttime = currenttime
                      Enemyturnendtime = enemyturnstarttime + enemyturnduration
                      While currenttime <= enemyturnendtime loop 
                          Clear()
                          currenttime = time()
                          Print (enemyturnendtime-currenttime)
                          Update()
                      Repeat
                      Playerturn = true
                      While playerturn == true loop
                          Clear()
                          Print(”press a button”)
                          *check the controls*
                          If *button was pressed* then
                              Print(”well done!”)
                              Sleep(1)
                              Playerturn = false // this ends player turn
                          Endif
                      Repeat
                  Repeat // end of main loop
                  

                  There are many ways to set up your program. This is just to show how time() could be used. Notice that I update currenttime inside the enemy turn loop. Without that, it’d never end. Also notice that there was no need to use time at all inside the player turn loop. Also notice the difference between == and = . == is when you’re asking a question and = makes it so. Fuze doesn’t warn you when you use = instead of == by accident, and it can really screw you up, so be careful!

                  Hope this helped :)

                  1 Reply Last reply Reply Quote 1
                  • waldron
                    waldron F last edited by

                    //global
                    bosstime = 0
                    //when you want to access the timer try this//
                    //Main loop
                    loop
                    if bosstime == 0 then
                    bosstime = time()
                    endif
                    // then some inner workings and triggers within the timer//
                    if time()-bosstime>=0 and time()-bosstime<4 then // if bosstime more then 0 it triggers, this will run until time is less then 4.
                    setspritespeed(boss,30,0)//required outcome
                    endif
                    if time()-bosstime>=4 and time()-bosstime<8 then // if bosstime more then 4 it triggers, this will run until time is less then 8.
                    setspritespeed(boss,-30,0)//required outcome
                    endif
                    //then to loop the time
                    if time()-bosstime>=8.0 then
                    bosstime = 0
                    endif

                    This is not my own code but it helped me immensely (cheers Jongjungbu)
                    you can modify this to your means

                    1 Reply Last reply Reply Quote 2
                    • landein207
                      landein207 last edited by

                      Ok tysm @waldron and @Jongjungbu for making the code i will test it later and see how i can change the code to what i need :)

                      1 Reply Last reply Reply Quote 3
                      • landein207
                        landein207 last edited by

                        Ps ty @toxibunny too i will see if is bether the way that you or waldron showed me for now thanks you two

                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post