Created
August 11, 2017 02:03
-
-
Save msg555/22206952ee4b6101de675535d0719ef6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class script { | |
scene@ g; | |
int frame; | |
script() { | |
@g = get_scene(); | |
frame = 0; | |
} | |
void step(int entities) { | |
++frame; | |
entity@ e = controller_entity(0); | |
if (@e != null) { | |
controllable@ pl = e.as_controllable(); | |
if (@pl != null) { | |
if (pl.taunt_intent() != 0) { | |
/* | |
mytrigger@ trig = mytrigger(); | |
trig.colour = 0xFFFF0000; | |
scripttrigger@ etrig = create_scripttrigger(@trig); | |
etrig.x(pl.x()); | |
etrig.y(pl.y()); | |
g.add_entity(@etrig.as_entity()); | |
*/ | |
myenemy@ enemy = myenemy(); | |
scriptenemy@ eenemy = create_scriptenemy(@enemy); | |
eenemy.x(pl.x()); | |
eenemy.y(pl.y()); | |
g.add_entity(@eenemy.as_entity()); | |
} | |
} | |
} | |
/* | |
for (int i = 0; i < entities; i++) { | |
entity@ e = entity_by_index(i); | |
scripttrigger@ st = e.as_scripttrigger(); | |
if (@st != null) { | |
mytrigger@ tr = cast<mytrigger@>(st.get_object()); | |
if (@tr != null) { | |
tr.colour = 0xFF000000; | |
} | |
} | |
} | |
*/ | |
entity@ pl = controller_entity(0); | |
if (@pl != null && pl.type_name() != "enemy_wolf") { | |
for (int i = 0; i < entities; i++) { | |
controllable@ e = entity_by_index(i).as_controllable(); | |
if (@e != null) { | |
if (e.type_name() == "enemy_wolf") { | |
controller_entity(0, @e); | |
break; | |
} | |
} | |
} | |
} | |
} | |
void entity_on_add(entity@ e) { | |
} | |
} | |
class mytrigger : trigger_base { | |
scene@ g; | |
script@ script; | |
scripttrigger@ self; | |
int colour; | |
int square_width; | |
bool btest; | |
string stest; | |
int _frame; | |
mytrigger() { | |
@g = get_scene(); | |
colour = 0xFFFFFFFF; | |
_frame = 0; | |
square_width = 100; | |
} | |
void init(script@ script, scripttrigger@ self) { | |
@this.script = @script; | |
@this.self = @self; | |
} | |
void step() { | |
++_frame; | |
colour = script.frame | 0x7F000000; | |
} | |
void editor_step() { | |
} | |
void draw(float) { | |
g.draw_rectangle_world(19, 0, self.x() - square_width, | |
self.y() - square_width, self.x() + square_width, | |
self.y() + square_width, _frame, colour); | |
} | |
void editor_draw(float) { | |
g.draw_rectangle_world(19, 0, self.x() - square_width, | |
self.y() - square_width, self.x() + square_width, | |
self.y() + square_width, 10, colour); | |
} | |
/* | |
void activate(controllable@ e) { | |
puts("ACTIVATE!"); | |
} | |
*/ | |
} | |
class myenemy : enemy_base { | |
scene@ g; | |
script@ script; | |
scriptenemy@ self; | |
int colour; | |
int square_width; | |
myenemy() { | |
@g = get_scene(); | |
colour = 0xFF00FF00; | |
square_width = 48; | |
} | |
void init(script@ script, scriptenemy@ self) { | |
@this.script = @script; | |
@this.self = @self; | |
} | |
void step() { | |
if (!self.ground()) { | |
self.set_speed_xy(self.x_speed(), self.y_speed() + 10); | |
} | |
} | |
void editor_step() { | |
} | |
void draw(float sub_frame) { | |
g.draw_rectangle_world(19, 0, self.x() - square_width, | |
self.y() - square_width, self.x() + square_width, | |
self.y() + square_width, 0, colour); | |
} | |
void editor_draw(float sub_frame) { | |
draw(sub_frame); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment