-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.py
More file actions
96 lines (80 loc) · 2.76 KB
/
Copy pathinit.py
File metadata and controls
96 lines (80 loc) · 2.76 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#init from camera
from bge import logic, render
from particle import Particle
from mathutils import Vector, Matrix
gdict = logic.globalDict
def draw():
camera = scene.objects["Camera"]
string = "BondCraft"
###draws bonds and changes text before frame load
atoms = gdict["atoms"].copy()
for atom in gdict["atoms"]:
###searches for everything connected to it and draws the bonds
#prevents two line draws
atoms.remove(atom)
atom.bond.draw_bonds(atoms)
for molecule in gdict["molecules"]:
molecule.draw_text()
for texture in gdict["textures"]:
texture.refresh(True)
if camera["laser"]:
crosshairs = scene.objects["Crosshairs"]
start = camera.worldPosition + camera.getAxisVect((1,-1,0))
end = camera.worldPosition - camera.getAxisVect((0,0,1))
render.drawLine(start,end,[0,1,0])
obj,point, normal = camera.rayCast(crosshairs,None,2000)
if obj:
render.drawLine(point,point + normal * 10000,[0,1,0])
obj.applyForce(-100 * normal)
def play(cont):
scene.restart()
gdict["play"] = True
UI = cont.owner.scene
UI.end()
def main(cont):
global scene
scene = logic.getCurrentScene()
scenes = logic.getSceneList()
camera = cont.owner
overlay = camera.actuators["Scene"]
# camera state 2 is in the menu
if camera.state == 2:
if "play" not in gdict:
# show menu
cont.activate(overlay)
render.showMouse(True)
logic.setGravity([0,0,-9.8])
else:
# start game
camera.state = 1
render.showMouse(False)
scene.objects["Floor"].endObject()
scene.objects["Spawn"].endObject()
logic.setGravity([0,0,0])
scene.objects["Cube"].visible = True
scene.objects["BondCraft"].visible = True
return
print("###############GAME START##################")
gdict.clear()
gdict["free"] = { "Hydrogen": set(),
"Carbon": set(),
"Oxygen": set(),
"Nitrogen": set(),
"Bromine": set()
}
gdict["cations"] = set()
gdict["atoms"] = set()
gdict["textures"] = []
gdict["molecules"] = set()
gdict["primary"] = "Hydrogen"
gdict["camera"] = scene.objects["Camera"]
gdict["prim_text"] = scene.objects["prim_text"]
gdict["prim_text"].resolution = 16
gdict["text"] = scene.objects["Text"]
gdict["text"].resolution = 16
#bind line drawing function
scene.pre_draw = [draw]
#slow down
#fps =1000
#logic.setLogicTicRate(fps)
#logic.setPhysicsTicRate(fps)