-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathminitracer_old.txt
58 lines (45 loc) · 1.54 KB
/
minitracer_old.txt
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@name Minitracer_old
@inputs DS:wirelink
@persist X Y RES CPU FOV
@strict
if (first()) {
#include "turbocolormap"
#runOnTick(1)
RES = 256 # how many pixels
CPU = 1000 # how much cpu in nanoseconds to use per tick
# dumbass cheat function I stole
function wirelink:initScreen(Resolution){
This[1048574,number] = 0 # Reset Screen and whatever was on it will be cleared.
This[1048569,number] = 2 # Set color mode to 2
This[1048575,number] = 1 # Apply changes
This[1048572,number] = Resolution # Set new resolution on Y (Height)
This[1048573,number] = Resolution # Set new resolution on X (Width)
}
FOV = 90 # Field of view (in degrees)
}
if( ->DS ){
DS:initScreen(RES)
}
event tick(){
while (opcounter() < softQuota() & cpuUsage() < CPU * 10 ^ -6) {
# Increment coordinates, wrapping when we reach screen edges
X++
if (X > RES) {
X = 0
Y++
if (Y > RES) {
Y = 0
}
}
# Calculate local camera direction using the pinhole camera model
CamScale = tan(FOV / 2)
CamDir = vec(
1,
(1 - 2 * (X + 0.5) / RES) * CamScale,
(1 - 2 * (Y + 0.5) / RES) * CamScale
):normalized()
Fwd = CamDir:rotate(entity():angles())
Ranger = rangerOffset(65536, entity():pos(), Fwd)
DS[Y * RES + X,number] = rgb2digi(turbomap(Ranger:distance() / 8192) * 255, 2)
}
}