Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bezier curve movement for enemies and objects
- function MapBezier(array,frames,t){ //array of points, frames, current frame
- if(length(array)==2){
- return [array[0][0] + (array[1][0]-array[0][0])/frames*t , array[0][1] + (array[1][1]-array[0][1])/frames*t];
- }else{
- let newarray = [];
- ascent(i in 0..length(array)-1){
- newarray = newarray ~ [[array[i][0] + (array[i+1][0]-array[i][0])/frames*t , array[i][1] + (array[i+1][1]-array[i][1])/frames*t]];
- }
- return MapBezier(newarray,frames,t);
- }
- }
- //Move from first to last xy points in a quadratic bezier curve motion, in "frames" amount of frames
- task SetMovePositionBezier(originalarray,frames){
- let currentpos;
- ascent(t in 0..frames){
- currentpos = MapBezier(originalarray,frames,t);
- SetX(currentpos[0]);
- SetY(currentpos[1]);
- yield;
- }
- }
- task Obj_Move_Bezier(obj,originalarray,frames){
- let currentpos;
- ascent(t in 0..frames){
- currentpos = MapBezier(originalarray,frames,t);
- Obj_SetX(obj,currentpos[0]);
- Obj_SetY(obj,currentpos[1]);
- yield;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement