• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision9dfb656ee21da72745acd2a5e79b3fe4ddcdb8d9 (tree)
Time2018-03-28 06:26:58
Authorsebastian_bugiu <sebastian_ <bugiu@head...>
Commitersebastian_bugiu <sebastian_

Log Message

Defining scripting language. Split language example into its own file.

Change Summary

Incremental Difference

diff -r aa9b273875c0 -r 9dfb656ee21d HotshotDesignDocs/scripting_language.docx
Binary file HotshotDesignDocs/scripting_language.docx has changed
diff -r aa9b273875c0 -r 9dfb656ee21d HotshotDesignDocs/scripting_language.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/HotshotDesignDocs/scripting_language.txt Wed Mar 28 00:26:58 2018 +0300
@@ -0,0 +1,98 @@
1+Cutscene cut_01
2+{
3+ Initial_conds
4+ {
5+ skybox SkyboxWorkspace0
6+ light_dir -1.0 0.0 0.0
7+ light_type directional
8+ light_power_scale 1.0
9+ light_diffuse_color 0.8 0.4 0.2 1.0
10+ light_specular_color 0.8 0.4 0.2 1.0
11+ ambient_light_upperhemi_lowerhemi_dir 0.0225 0.0375 0.052 0.075 0.02925 0.0219375 0.014625 0.04875 -1.0 0.0 0.0
12+ obj CargoShip0
13+ {
14+ mesh ship_human_big0
15+ type cargo_ship
16+ position -500.0 0.0 -500.0
17+ orientation 0.0 1.0 0.0 0.0
18+ speed 0.0 0.0 0.0
19+ ai 0
20+ friendly 0
21+ health 1000
22+ }
23+
24+ obj Defender0
25+ {
26+ mesh ship_human1
27+ type fighter_ship
28+ position -500.0 0.0 300.0
29+ orientation 0.0 1.0 0.0 180.0
30+ speed 0.0 0.0 -0.0
31+ ai 0
32+ friendly 1
33+ behavior defensive
34+ health 100
35+ }
36+ }
37+Obj_event
38+{
39+ Obj Defender0
40+ Set_speed 20.0 // instantaneous change
41+}
42+Camera_event
43+{
44+ Pos 0.0 0.0 50.0
45+ Look_at Defender0
46+ End_delay 1 secs
47+
48+}
49+Camera_attach
50+{
51+ Start_delay 2 secs
52+ Attach Defender0
53+ Pos 50.0 0.0 0.0 // relative to obj
54+ Look_at Defender0
55+ End_delay 3000 ms
56+}
57+Obj_event
58+{
59+ Obj Defender0
60+ Change_speed 20.0 // change ship speed with the maximum delta/second
61+}
62+Obj_event
63+{
64+ Obj Defender0
65+ Change_speed 50.0
66+ Completion_time 5 secs // The speed must be reached within 5 secs if the ship acceleration permits it
67+}
68+Parallel_task
69+{
70+ // We need a way to execute events in parallel and advance once all have been completed
71+ Obj_event
72+ {
73+ Obj Defender0
74+ Change_speed 20.0
75+ }
76+ Camera_detach
77+ {
78+ Start_delay 2 secs
79+ }
80+ Obj_event
81+ {
82+ obj Defender1
83+ {
84+ mesh ship_human1
85+ type fighter_ship
86+ position -500.0 0.0 300.0
87+ orientation 0.0 1.0 0.0 180.0
88+ speed 0.0 0.0 -0.0
89+ ai 0
90+ friendly 1
91+ behavior defensive
92+ health 100
93+ }
94+
95+ spawn Defender1
96+ }
97+}
98+}
diff -r aa9b273875c0 -r 9dfb656ee21d core/src/headwayEnt/blackholedarksun/parser/grammar.cup
--- a/core/src/headwayEnt/blackholedarksun/parser/grammar.cup Tue Mar 27 00:04:23 2018 +0300
+++ b/core/src/headwayEnt/blackholedarksun/parser/grammar.cup Wed Mar 28 00:26:58 2018 +0300
@@ -0,0 +1,55 @@
1+import java_cup.runtime.*;
2+
3+/* Preliminaries to set up and use the scanner. */
4+init with {: scanner.init(); :};
5+scan with {: return scanner.next_token(); :};
6+
7+/* Terminals (tokens returned by the scanner). */
8+terminal SEMI, PLUS, MINUS, TIMES, DIVIDE, MOD;
9+terminal UMINUS, LPAREN, RPAREN;
10+terminal Integer NUMBER;
11+
12+/* Non-terminals */
13+non terminal expr_list, expr_part;
14+non terminal Integer expr;
15+
16+/* Precedences */
17+precedence left PLUS, MINUS;
18+precedence left TIMES, DIVIDE, MOD;
19+precedence left UMINUS;
20+
21+/* The grammar */
22+expr_list ::= expr_list expr_part
23+ |
24+ expr_part;
25+
26+expr_part ::= expr:e
27+ {: System.out.println("= " + e); :}
28+ SEMI
29+ ;
30+
31+expr ::= expr:e1 PLUS expr:e2
32+ {: RESULT = new Integer(e1.intValue() + e2.intValue()); :}
33+ |
34+ expr:e1 MINUS expr:e2
35+ {: RESULT = new Integer(e1.intValue() - e2.intValue()); :}
36+ |
37+ expr:e1 TIMES expr:e2
38+ {: RESULT = new Integer(e1.intValue() * e2.intValue()); :}
39+ |
40+ expr:e1 DIVIDE expr:e2
41+ {: RESULT = new Integer(e1.intValue() / e2.intValue()); :}
42+ |
43+ expr:e1 MOD expr:e2
44+ {: RESULT = new Integer(e1.intValue() % e2.intValue()); :}
45+ |
46+ NUMBER:n
47+ {: RESULT = n; :}
48+ |
49+ MINUS expr:e
50+ {: RESULT = new Integer(0 - e.intValue()); :}
51+ %prec UMINUS
52+ |
53+ LPAREN expr:e RPAREN
54+ {: RESULT = e; :}
55+ ;
\ No newline at end of file
diff -r aa9b273875c0 -r 9dfb656ee21d core/src/headwayEnt/blackholedarksun/parser/lexer.flex
--- a/core/src/headwayEnt/blackholedarksun/parser/lexer.flex Tue Mar 27 00:04:23 2018 +0300
+++ b/core/src/headwayEnt/blackholedarksun/parser/lexer.flex Wed Mar 28 00:26:58 2018 +0300
@@ -0,0 +1,86 @@
1+import java_cup.runtime.*;
2+
3+ /**
4+ * This class is a simple example lexer.
5+ */
6+ %%
7+
8+ %class Lexer
9+ %unicode
10+ %cup
11+ %line
12+ %column
13+
14+ %{
15+ StringBuffer string = new StringBuffer();
16+
17+ private Symbol symbol(int type) {
18+ return new Symbol(type, yyline, yycolumn);
19+ }
20+ private Symbol symbol(int type, Object value) {
21+ return new Symbol(type, yyline, yycolumn, value);
22+ }
23+ %}
24+
25+ LineTerminator = \r|\n|\r\n
26+ InputCharacter = [^\r\n]
27+ WhiteSpace = {LineTerminator} | [ \t\f]
28+
29+ /* comments */
30+ Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment}
31+
32+ TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
33+ // Comment can be the last line of the file, without line terminator.
34+ EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
35+ DocumentationComment = "/**" {CommentContent} "*"+ "/"
36+ CommentContent = ( [^*] | \*+ [^/*] )*
37+
38+ Identifier = [:jletter:] [:jletterdigit:]*
39+
40+ DecIntegerLiteral = 0 | [1-9][0-9]*
41+
42+ %state STRING
43+
44+ %%
45+
46+ /* keywords */
47+ <YYINITIAL> "abstract" { return symbol(sym.ABSTRACT); }
48+ <YYINITIAL> "boolean" { return symbol(sym.BOOLEAN); }
49+ <YYINITIAL> "break" { return symbol(sym.BREAK); }
50+
51+ <YYINITIAL> {
52+ /* identifiers */
53+ {Identifier} { return symbol(sym.IDENTIFIER); }
54+
55+ /* literals */
56+ {DecIntegerLiteral} { return symbol(sym.INTEGER_LITERAL); }
57+ \" { string.setLength(0); yybegin(STRING); }
58+
59+ /* operators */
60+ "=" { return symbol(sym.EQ); }
61+ "==" { return symbol(sym.EQEQ); }
62+ "+" { return symbol(sym.PLUS); }
63+
64+ /* comments */
65+ {Comment} { /* ignore */ }
66+
67+ /* whitespace */
68+ {WhiteSpace} { /* ignore */ }
69+ }
70+
71+ <STRING> {
72+ \" { yybegin(YYINITIAL);
73+ return symbol(sym.STRING_LITERAL,
74+ string.toString()); }
75+ [^\n\r\"\\]+ { string.append( yytext() ); }
76+ \\t { string.append('\t'); }
77+ \\n { string.append('\n'); }
78+
79+ \\r { string.append('\r'); }
80+ \\\" { string.append('\"'); }
81+ \\ { string.append('\\'); }
82+ }
83+
84+ /* error fallback */
85+ [^] { throw new Error("Illegal character <"+
86+ yytext()+">"); }
\ No newline at end of file