-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.swift
38 lines (32 loc) · 923 Bytes
/
App.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// File.swift
// File
//
// Created by Christophe Bronner on 2021-09-02.
//
import RaylibKit
@main struct InputMouse: Applet {
var position = Vector2(-100)
var color = Color.darkBlue
init() {
Window.create(800, by: 450, title: "Example - Core - Input Mouse")
Application.target(fps: 60)
}
mutating func update() {
position = Mouse.position
switch true {
case Mouse.left.isPressed: color = .maroon
case Mouse.middle.isPressed: color = .lime
case Mouse.right.isPressed: color = .darkBlue
case Mouse.side.isPressed: color = .purple
case Mouse.extra.isPressed: color = .yellow
case Mouse.forward.isPressed: color = .orange
case Mouse.backward.isPressed: color = .beige
default: break
}
}
func draw() {
Renderer2D.text("Move ball with mouse and use mouse buttons to change color", at: 10, 10, color: .darkGray)
Renderer2D.circle(at: position, radius: 40, color: color)
}
}