remove debug messages, fix some physical errors
This commit is contained in:
parent
7fbd24b85d
commit
ec5fc69ae5
31
src/main.zig
31
src/main.zig
@ -113,6 +113,18 @@ const Emitter = struct {
|
||||
if(at.init_done != 1)
|
||||
{
|
||||
at.init(.{.a=.{.x=@floatFromInt(rl.getMouseX() - screenWidth / 2),.y=@floatFromInt(rl.getMouseY() - screenHeight / 2),.z=0}});
|
||||
at.mode = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_middle)) {
|
||||
for (att) |*at|
|
||||
{
|
||||
if(at.init_done != 1)
|
||||
{
|
||||
at.init(.{.a=.{.x=@floatFromInt(rl.getMouseX() - screenWidth / 2),.y=@floatFromInt(rl.getMouseY() - screenHeight / 2),.z=0}});
|
||||
at.mode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -127,9 +139,15 @@ const Emitter = struct {
|
||||
//p.applyGravity(2);
|
||||
for (att) |at|
|
||||
{
|
||||
//std.debug.print("force:{}\n",.{at.attract(p.*)});
|
||||
if(at.mode == 0)
|
||||
{
|
||||
p.applyForce(at.attract(p.*));
|
||||
}
|
||||
else
|
||||
{
|
||||
p.applyForce(at.repel(p.*));
|
||||
}
|
||||
}
|
||||
p.update();
|
||||
|
||||
if(p.position.a.x < 10000 and p.position.a.x > -10000)
|
||||
@ -150,6 +168,7 @@ const Emitter = struct {
|
||||
const Attractor = struct {
|
||||
vec: pr.Vec,
|
||||
init_done : u8 = 0,
|
||||
mode : u8 = 0,
|
||||
pub fn init(self : *Attractor, vec : pr.Vec) void
|
||||
{
|
||||
self.vec = vec;
|
||||
@ -161,8 +180,8 @@ const Attractor = struct {
|
||||
const distance = self.vec.sub(particle.position);
|
||||
var force: pr.Vec = undefined;
|
||||
if (distance.a.x != 0 and distance.a.y != 0) {
|
||||
force.a.x = distance.a.x / 1000;
|
||||
force.a.y = distance.a.y / 1000;
|
||||
force.a.x = distance.a.x * @abs(1/distance.a.x);
|
||||
force.a.y = distance.a.y * @abs(1/distance.a.y);
|
||||
force.a.z = 0;
|
||||
}
|
||||
return force;
|
||||
@ -178,8 +197,8 @@ const Attractor = struct {
|
||||
const distance = self.vec.sub(particle.position);
|
||||
var force: pr.Vec = undefined;
|
||||
if (distance.a.x != 0 and distance.a.y != 0) {
|
||||
force.a.x = -distance.a.x / 1000;
|
||||
force.a.y = -distance.a.y / 1000;
|
||||
force.a.x = -distance.a.x * @abs(1/distance.a.x);
|
||||
force.a.y = -distance.a.y * @abs(1/distance.a.y);
|
||||
force.a.z = 0;
|
||||
}
|
||||
return force;
|
||||
@ -273,8 +292,6 @@ pub fn main() anyerror!void {
|
||||
_ = rg.guiSlider(rectangle(10, 170, 600, 10), "-3", "3", &value2, ItoF(-100), ItoF(100));
|
||||
_ = rg.guiSlider(rectangle(10, 190, 600, 10), "-3", "3", &value3, -100, 100);
|
||||
_ = rg.guiColorPicker(rectangle(10,200,300,100),"Choose Color", &color);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user