Skip to content

RattleyCooper/framecounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

framecounter

Schedule code to run after/every X frames.

Install

nimble install https://github.com/RattleyCooper/framecounter

Example

import framecounter


type 
  Cat = ref object
    name: string

var cats = FrameCounter[Cat](fps: 60)

var scrubs = Cat(name: "Scrubs")
var shadow = Cat(name: "Shadow")

cats.run scrubs.after(60) do(c: var Cat):
  c.name = "Not Scrubs"

cats.run shadow.after(60) do(c: var Cat):
  c.name = "Not Shadow"

var c = 0
cats.run scrubs.every(30) do(sc: var Cat):
  echo "repeating"
  if c == 3:
    echo scrubs.name
    echo shadow.name
    quit(QuitSuccess)
  c += 1
  echo c

echo scrubs.name
echo shadow.name

var dt: float32 
# assume our delta time is being updated.
while true:
  # Do stuff like detecting inputs
  
  cats.tick() # tick frame counter.

About

Schedule code to run after/every X frames.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages