Game with turns
-
There’s functions in fuze that keep track of time, so all that stuff is definitely possible :)
-
That means i need to check what functions track the time but thanks i didn't knew that
-
@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
-
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 :)
-
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
-
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)
-
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 :)
-
//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
endifThis is not my own code but it helped me immensely (cheers Jongjungbu)
you can modify this to your means -
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 :)
-
Ps ty @toxibunny too i will see if is bether the way that you or waldron showed me for now thanks you two