# How to create a graphic simulator?

**URL:** https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256
**Category:** General Usage
**Tags:** question, graphics, simulations, games
**Created:** [February 8, 2023, 6:12am UTC](https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256 "2023-02-08T06:12:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Maddy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maddy/32/210658_2.png) [@Maddy](https://discourse.julialang.org/u/Maddy)
#### Post date: [February 8, 2023, 6:12am UTC](https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256/1 "2023-02-08T06:12:45Z")

</div>

Julia has MANY packages to create static vector graphics. But I want to create a simulation. A **RealTime** simulation. I don’t want to create GIFs or MP4s or anything. Realtime simulations that render in a window. _And I am not talking about plots either._ I want to simulate particles with my own physics. How do I do it? I want something that has the following:

- A graphics window.
- High-speed rendering
- CLEAN-looking graphics. (A circle should look smooth, maybe anti-aliasing or vectors idk)
- I don’t know technical stuff but ig in 2D rendering, objects are stored as sprites.
- I should be able to create objects like circles, rectangles, lines, curves, etc…
- It should have a render loop
- I should be able to set a frame rate limit
- I should be able to time things (movement of sprites… perhaps frame by frame?)
- And finally… at least some ease of use.

GameZero.jl seems pretty good for that but I don’t think it’s high performance. As the creators suggest, it’s for “Beginner purposes”. Besides, I don’t see any frame rate option there (please tell me if I’m wrong).  
ModernGL + GLFW seems promising but it’s almost the same as using the native c++. So why do it in Julia if I am using c++ like syntax after all? (And I really don’t want to learn c++ at the moment)

Luxor provides static vectors (It’s great looking but I want to simulate in real-time, not prerender)

Makie seems to be a plotting thing… (please correct me if I’m wrong)

SFML.jl library seems to be totally abandoned by the creator. (CSFML doesn’t seem correct for some syntactical reason)

GTK.jl seems ugly looking, inefficient and what not.

Please recommend a way out. I want to create something like [Particle Life](https://youtu.be/p4YirERTVF0) but extended as per my own needs. I have no issues spending time learning. But at least the final result should be promising and fast. (do recommend examples and tutorials for a library/package if you can think of any.)

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [February 8, 2023, 9:13am UTC](https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256/2 "2023-02-08T09:13:07Z")

</div>

> [@Maddy](#):
>
> Makie seems to be a plotting thing… (please correct me if I’m wrong)

Let me correct you, because you’re wrong 😃

Plotting is just visualization with certain conveniences, like axes, colorbars, etc. But all these are built from primitives like scatters and lines and those you can use directly for lower-level simulations. I assume you just want a blank canvas in which to draw things, and update them.

If you don’t want any plotting bells and whistles, you use a plain `Scene`, for example with a `campixel!` function as camera parameter, which will make it so you draw things in pixel coordinates.

```julia
using GLMakie

begin
    s = Scene(resolution = (800, 800), camera = campixel!)
    data = Observable(rand(Point2f, 10_000) .* Point2f(800, 800))
    scatter!(s, data, color = rand(10_000))
    screen = display(s)
    task = @async while isopen(screen)
        data[] .+= randn.(Point2f)
        notify(data)
        sleep(1/60)
    end
    Base.errormonitor(task)
end

```

[https://i.imgur.com/OrDZVRb.mp4](https://i.imgur.com/OrDZVRb.mp4)

---

<div class="post-metadata">

### Author: ![Maddy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maddy/32/210658_2.png) [@Maddy](https://discourse.julialang.org/u/Maddy)
#### Post date: [February 8, 2023, 9:22am UTC](https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256/3 "2023-02-08T09:22:27Z")

</div>

😭😭 Thank you so much!!!

Assuming that’s a live window, how do I time things? sleep would stop all the processes I assume, including the computational work in the bg.  
Apart from that, just 1 question, Ummm… is it like… fast? REAL FAST? can I get high fps here?  
Also, any easy-to-follow tutorials.  
How to make things a little more interactive? (not buttons but mouse clicks and stuff) And what is that? Scatter? I was wishing for something like:  
draw(circle(radius=20, x=500, y=500, color=:red))  
where exactly do I put such a function to loop if I have to time things that way?

These might be dumb questions (I’m pretty new in Julia, been like… 4 days. Although the syntax seems familiar due to python)  
Anyways, Thank you so much DUDE!!!

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [February 8, 2023, 9:30am UTC](https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256/4 "2023-02-08T09:30:25Z")

</div>

The update loop is in an `@async` block so you can still do other things at the same time.

For all the other questions, have a look at the docs, for example here:

- [Observables & Interaction](https://docs.makie.org/stable/documentation/nodes/)
- [Scene tutorial](https://docs.makie.org/stable/tutorials/scenes/)

---

<div class="post-metadata">

### Author: ![Maddy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maddy/32/210658_2.png) [@Maddy](https://discourse.julialang.org/u/Maddy)
#### Post date: [February 8, 2023, 9:59am UTC](https://discourse.julialang.org/t/how-to-create-a-graphic-simulator/94256/5 "2023-02-08T09:59:04Z")

</div>

Thank you so very much!
