Skip to content

Commit 1ecf163

Browse files
committed
no rotation
1 parent ad16c09 commit 1ecf163

File tree

19 files changed

+484
-6
lines changed

19 files changed

+484
-6
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ This method returns the angular velocity of the agent in radians per second and
215215
> `int id()`<br>
216216
This method returns a unique id of the agent.
217217
218+
> `void prevent_rotation()`<br>
219+
Prevents the agent from rotating. Probably best to call in the init function. Good for platformer type movement. Technically sets the moment of inertia to infinity. &#x246D; New in 1.4.
220+
221+
> `void allow_rotation()` <br>
222+
Allows the agent to rotate, setting the moment of inertia to the default number (based on the mass and shape of the agent). &#x246D; New in 1.4.
223+
218224
Motion Control for Oriented Agents
219225
---
220226

examples/platformer/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
TARGET := bin/enviro
2+
3+
all:
4+
$(MAKE) -C src all
5+
6+
clean:
7+
$(MAKE) -C src clean
8+
9+
10+

examples/platformer/config.json

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
3+
"name": "My Enviro Project",
4+
"ip": "0.0.0.0",
5+
"port": 8765,
6+
7+
"buttons": [],
8+
9+
"agents": [
10+
{
11+
"definition": "defs/guy.json",
12+
"style": { "fill": "lightblue", "stroke": "black" },
13+
"position": {
14+
"x": 0,
15+
"y": 135,
16+
"theta": 0
17+
}
18+
},
19+
{
20+
"definition": "defs/bumper.json",
21+
"style": { "fill": "red", "stroke": "none" },
22+
"position": {
23+
"x": -145,
24+
"y": 68,
25+
"theta": 0
26+
}
27+
},
28+
{
29+
"definition": "defs/bumper.json",
30+
"style": { "fill": "red", "stroke": "none" },
31+
"position": {
32+
"x": 145,
33+
"y": 68,
34+
"theta": 0
35+
}
36+
},
37+
{
38+
"definition": "defs/ghost.json",
39+
"style": { "fill": "lightgreen", "stroke": "black" },
40+
"position": {
41+
"x": 0,
42+
"y": 80,
43+
"theta": 0
44+
}
45+
}
46+
47+
],
48+
49+
"statics": [
50+
{
51+
"style": { "fill": "gray", "stroke": "none" },
52+
"shape": [
53+
{ "x": -350, "y": -200 },
54+
{ "x": -350, "y": 200 },
55+
{ "x": -340, "y": 200 },
56+
{ "x": -340, "y": -200 }
57+
]
58+
},
59+
{
60+
"style": { "fill": "gray", "stroke": "none" },
61+
"shape": [
62+
{ "x": 350, "y": -200 },
63+
{ "x": 350, "y": 200 },
64+
{ "x": 340, "y": 200 },
65+
{ "x": 340, "y": -200 }
66+
]
67+
},
68+
{
69+
"style": { "fill": "gray", "stroke": "none" },
70+
"shape": [
71+
{ "x": -350, "y": 200 },
72+
{ "x": 350, "y": 200 },
73+
{ "x": 350, "y": 190 },
74+
{ "x": -350, "y": 190 }
75+
]
76+
},
77+
{
78+
"style": { "fill": "gray", "stroke": "none" },
79+
"shape": [
80+
{ "x": -350, "y": -200 },
81+
{ "x": 350, "y": -200 },
82+
{ "x": 350, "y": -190 },
83+
{ "x": -350, "y": -190 }
84+
]
85+
},
86+
87+
{
88+
"style": { "fill": "gray", "stroke": "none" },
89+
"shape": [
90+
{ "x": -350, "y": 125 },
91+
{ "x": -250, "y": 125 },
92+
{ "x": -250, "y": 115 },
93+
{ "x": -350, "y": 115 }
94+
]
95+
},
96+
97+
{
98+
"style": { "fill": "gray", "stroke": "none" },
99+
"shape": [
100+
{ "x": -150, "y": 90 },
101+
{ "x": 150, "y": 90 },
102+
{ "x": 150, "y": 80 },
103+
{ "x": -150, "y": 80 }
104+
]
105+
},
106+
107+
{
108+
"style": { "fill": "gray", "stroke": "none" },
109+
"shape": [
110+
{ "x": 350, "y": 55 },
111+
{ "x": 250, "y": 55 },
112+
{ "x": 250, "y": 45 },
113+
{ "x": 350, "y": 45 }
114+
]
115+
}
116+
117+
]
118+
119+
}

examples/platformer/defs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Put agent definitions in this folder.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Bumper",
3+
"type": "static",
4+
"description": "Replace this string with a description",
5+
"shape": [
6+
{ "x": -5, "y": 10 },
7+
{ "x": 5, "y": 10 },
8+
{ "x": 5, "y": -10 },
9+
{ "x": -5, "y": -10 }
10+
],
11+
"friction": {
12+
"collision": 5,
13+
"linear": 40,
14+
"rotational": 600
15+
},
16+
"sensors": [],
17+
"mass": 1,
18+
"controller": "lib/bumper.so"
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Ghost",
3+
"type": "dynamic",
4+
"description": "Replace this string with a description",
5+
"shape": [
6+
{ "x": -10, "y": 15 },
7+
{ "x": 10, "y": 15 },
8+
{ "x": 10, "y": -15 },
9+
{ "x": 0, "y": -17 },
10+
{ "x": -10, "y": -15 }
11+
12+
],
13+
"friction": {
14+
"collision": 5,
15+
"linear": 40,
16+
"rotational": 600
17+
},
18+
"sensors": [],
19+
"mass": 1,
20+
"controller": "lib/ghost.so"
21+
}

examples/platformer/defs/guy.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Guy",
3+
"type": "dynamic",
4+
"description": "Replace this string with a description",
5+
"shape": [
6+
{ "x": -10, "y": 15 },
7+
{ "x": 10, "y": 15 },
8+
{ "x": 10, "y": -15 },
9+
{ "x": -10, "y": -15 }
10+
],
11+
"friction": {
12+
"collision": 0,
13+
"linear": 0,
14+
"rotational": 0
15+
},
16+
"sensors": [
17+
{
18+
"type": "range",
19+
"location": { "x": 10, "y": 15 },
20+
"direction": 1.57
21+
},
22+
{
23+
"type": "range",
24+
"location": { "x": -10, "y": 15 },
25+
"direction": 1.57
26+
}
27+
],
28+
"mass": 1,
29+
"controller": "lib/guy.so"
30+
}

examples/platformer/lib/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Shared object libraries will be place here by make.

examples/platformer/src/Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#Architecture
2+
ARCH := $(shell uname -m)
3+
4+
#Compilers
5+
CC := g++ -std=c++17 -Wno-psabi
6+
7+
#The Target Library
8+
9+
#The Directories, Source, Includes, Objects, Binary and Resources
10+
SRCEXT := cc
11+
12+
# Directories
13+
CHIPDIR := /usr/local/src/Chipmunk2D
14+
ENVIRODIR := ../../../server/include
15+
16+
#Flags, Libraries and Includes
17+
CFLAGS := -ggdb -shared -fPIC
18+
INCLUDE := -I $(ENVIRODIR) -I $(CHIPDIR)/include/chipmunk
19+
20+
#Files
21+
22+
TARGETDIR := ../lib
23+
SOURCES := $(wildcard *.cc)
24+
HEADERS := $(wildcard *.h)
25+
TARGETS := $(patsubst %.cc,%.so,$(wildcard *.cc))
26+
FULL_TARGETS := $(addprefix $(TARGETDIR)/, $(TARGETS))
27+
28+
#Default Make
29+
all: $(FULL_TARGETS)
30+
31+
#Clean only Objects
32+
clean:
33+
@$(RM) -rf $(TARGETDIR)/*.so
34+
35+
# Compile
36+
$(TARGETDIR)/%.so: %.cc %.h
37+
$(CC) $(CFLAGS) $(INCLUDE) $< -o $@
38+

examples/platformer/src/bumper.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
#include "bumper.h"
3+
4+
using namespace enviro;
5+
6+
// Put your implementations here

0 commit comments

Comments
 (0)