This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simdemo.html
87 lines (77 loc) · 2.98 KB
/
simdemo.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Entirely in-browser robot simulation demo (no physics)</title>
<!--<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>-->
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.3.2/dojo/dojo.xd.js" type="text/javascript"></script>
<!-- <script src="../sim/client/dojoroot/dojo/dojo.js" type="text/javascript"></script>-->
<script src="skulpt/dist/skulpt-uncomp.js" type="text/javascript"></script>
<script src="CodeMirror-0.63/js/codemirror.js" type="text/javascript"></script>
<script src="simdemo.js" type="text/javascript"></script>
<style type="text/css">
.CodeMirror-line-numbers {
width: 2.2em;
color: #aaa;
background-color: #eee;
text-align: right;
padding: .4em;
margin: 0;
font-family: monospace;
font-size: 10pt;
line-height: 1.1em;
}
</style>
</head>
<body>
<p>
<strong>API:</strong>
<br>setspeed (motor A, motor B)
<br>yield (time in seconds)
</p>
<div id="simDisplay" style="width: 500px; height: 500px; border: solid 1px black; float: left"></div>
<div style="float: left">
<textarea rows="30" cols="30" id="code">
def main():
i=0
setspeed(120,80) # a lazy curl
yield 3.5
while (i<4):
spin(70)
yield 1 # spin for 1 sec
setspeed(60,60)
yield 2 # forward for 2 secs
i += 1
spin(-100)
yield 1
j = 120
while (j>0):
# slow down gradually
setspeed(j,j)
yield 1
j += -15
def spin(value):
# make robot spin on spot
# positive value spins clockwise
setspeed(value, -value)
</textarea>
<input type="button" value="Load and run code" name=button1 onclick="loadCode()">
<input type="button" value="Stop" name=button2 onclick="stopAnim()">
<input type="button" value="Reset robot" name=button3 onclick="setupAnim()">
</div>
<div style="clear: both;">
Frames/second:
<form name="nextform">
<input type="button" name="ratebutton1" value="-" onclick="changeUpdateRate(-1)">
<input type="text" name="rateDisplay" value=15>
<input type="button" name="ratebutton2" value="+" onclick="changeUpdateRate(1)">
</form>
<p>
Uses <a href="http://www.skulpt.org">Skulpt</a> for Python->Javascript compilation.<br/>
Uses <a href="http://www.dojotoolkit.org">Dojo</a> gfx library for rendering (hosted at Google AJAX lib API).<br/>
Uses <a href="http://marijn.haverbeke.nl/codemirror/">CodeMirror</a> Javascript editor interface.
</p>
</div>
</body>