Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, howardR), 472 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: beginner problem with loops [Re: Saschaw04] #450016
04/04/15 17:57
04/04/15 17:57

M
Malice
Unregistered
Malice
Unregistered
M



Welcome as long as you understand why it works and why it didn't before which is what the Great Kartoffel, was telling you.

Keep coding and keep learning, btw Welcome to 3dgs

Re: beginner problem with loops [Re: ] #450018
04/04/15 19:01
04/04/15 19:01
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
And, you might want to increment/decrement with "time_step / 16", and wait(1) (1 frame). Otherwise, your function stops for 1 second (wait(-1)) and runs again... With time_step / 16 your function runs with the frames per second speed. laugh

Not that its vital for a flashlight, but sometimes you might want to do other stuff around that if statement, that has to run more times per second...so use wait(-1) only when its trivial.

Last edited by EpsiloN; 04/04/15 19:02.

Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: beginner problem with loops [Re: EpsiloN] #450034
04/05/15 10:12
04/05/15 10:12
Joined: Apr 2015
Posts: 29
Germany
Saschaw04 Offline OP
Newbie
Saschaw04  Offline OP
Newbie

Joined: Apr 2015
Posts: 29
Germany
Nur damit ich das richtig verstanden habe. Wenn ich sowas hier habe:

while(1){

if(key_f) Funktion();

wait(1);
}

Dann wird die function Funktion jeden Frame ausgelöst, weil es in einer Schleife mit wait(1) steht. Bei einer fps von 60 wird die Funktion also 60 mal in der Sekunde ausgelöst. Wenn ich also kurz auf die F-Taste drücke, sagen wir mal (1/20 Sekunden gedrückt) dann wird die Funktion (60/20) 3mal parallel durchgeführt und deshalb sinkt der Countdown schneller.

ISt das so ungefähr verstanden?


-- started with programming on march 2015 --
-- living in Germany near Dortmund --
Re: beginner problem with loops [Re: Saschaw04] #450042
04/05/15 15:36
04/05/15 15:36

M
Malice
Unregistered
Malice
Unregistered
M



You understand perfectly- Remember to use a key_lock of some type because the very person will hold the key longer then 1 cycle.
BTW wait(1) is a frame not a time measure - it changes a bit for each cycle - however in your example of 60 fps then you are perfectly correct.

As a personal note, the new users who learn the fastest and best are people like you who want to understand the logic not just be hand a piece of code. My complements to you for start on a good foot.

Last edited by Malice; 04/05/15 15:37.
Re: beginner problem with loops [Re: ] #450043
04/05/15 16:04
04/05/15 16:04
Joined: Apr 2015
Posts: 29
Germany
Saschaw04 Offline OP
Newbie
Saschaw04  Offline OP
Newbie

Joined: Apr 2015
Posts: 29
Germany
@Malice
Thank you for your opinion. I will give my best laugh


-- started with programming on march 2015 --
-- living in Germany near Dortmund --
Page 3 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1