#Timeer

1 messages ยท Page 1 of 1 (latest)

vernal axle
#

How would I run a line of code foe 15 seconds every 1 millisecond

surreal frostBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
How would I run a line of code foe 15 seconds every 1 millisecond

You can achieve this by using a Timer in Java. Here's an example code snippet:

import java.util.Timer;
import java.util.TimerTask;

public class Main {
    public static void main(String[] args) {
        Timer timer = new Timer();
        
        timer.scheduleAtFixedRate(new TimerTask() {
            int count = 0;
            
            @Override
            public void run() {
                System.out.println("Code to run every 1 millisecond");
                
                count++;
                if (count == 15000) { // 15 seconds * 1000 milliseconds
                    timer.cancel();
                }
            }
        }, 0, 1); // initial delay of 0 milliseconds, repeat every 1 millisecond
    }
}

In this code snippet, we create a Timer object and schedule a TimerTask to run every millisecond. Inside the TimerTask's run method, we print a message and increment a counter. When the counter reaches 15000 (15 seconds * 1000 milliseconds), we cancel the timer to stop further execution.

Remember to handle exceptions that may be thrown by the Timer class and its methods.

vernal axle
#

ty

stuck grail
#

huh what is the use case?

vernal axle
#

im remaking destiny as a 2d java game

gentle leaf
vernal axle
#

its weird

#

and fps

#

im trying to make ti as close as possible

gentle leaf
#

making a game without is nonsense

vernal axle
#

its tied to like 3 diff things

#

many reasons people with higher fps take more damage

#

are able t stay in air longer

stuck grail
vernal axle
#

and a bunch of other weird interactions

vernal axle
gentle leaf
stuck grail
#

tick system

vernal axle
#

its so buggy thers multiple answers

#

its a broken game

gentle leaf
#

it's like saying a car without an engine

vernal axle
gentle leaf
vernal axle
#

destiny 2*

gentle leaf
#

and while it's only speculative

#

it's still here

gentle leaf
vernal axle
#

its broken is what im saying

#

imma go do my hw

gentle leaf
#

even if it is broken

#

it must have a tick system

#

if you don't have a tick system

#

you don't have a game

#

as simple as that

vernal axle
#

its a year 1 java class

gentle leaf
vernal axle
#

imma just back out of this conversation

#

i need to concentrate

gentle leaf
#

You need to make a tick system