public void SetCharacter(Character c, int carSprite, CharacterDirection carSpriteDir, int view = 0, int loop = 0, int frame = 0) { this.DetachCharacter(); int carl = 0; int carw = 0; if (carSpriteDir == eDirectionDown || carSpriteDir == eDirectionUp) { carl = Game.SpriteHeight[carSprite]; carw = Game.SpriteWidth[carSprite]; } else if (carSpriteDir == eDirectionLeft || carSpriteDir == eDirectionRight) { carl = Game.SpriteWidth[carSprite]; carw = Game.SpriteHeight[carSprite]; } else { AbortGame("Source car sprite direction cannot be diagonal, please provide sprite having one of the following directions: left, right, up or down."); return; } this.c = c; this.carSprite = carSprite; this.carSpriteAngle = RotatedView.AngleForLoop(carSpriteDir); this.viewFrame = Game.GetViewFrame(view, loop, frame); this.bodyLength = IntToFloat(carl); this.bodyWidth = IntToFloat(carw); this.collPointOff[0] = VectorF.create(carl / 2, -carw / 2); this.collPointOff[1] = VectorF.create(carl / 2, carw / 2); this.collPointOff[2] = VectorF.create(-carl / 2, carw / 2); this.collPointOff[3] = VectorF.create(-carl / 2, -carw / 2); this.SyncCharacter(); }
public static DynamicSprite[] CreateAllLoops(int view, int base_loop = 0) { if (view >= Game.ViewCount) { return(null); } int loop = 0; int loop_count = Game.GetLoopCountForView(view); int frames_total = 0; for (loop = 0; loop < loop_count; loop += 1) { if (loop == base_loop) { continue; } frames_total += Game.GetFrameCountForLoop(view, loop); } DynamicSprite[] spr_all = new DynamicSprite[frames_total]; int write_at = 0; for (loop = 0; loop < loop_count; loop += 1) { if (loop == base_loop) { continue; } int frame_count = Game.GetFrameCountForLoop(view, loop); DynamicSprite[] spr_loop = RotatedView.CreateLoop(view, loop, base_loop); int frame = 0; for (frame = 0; frame < frame_count; frame += 1) { spr_all[write_at + frame] = spr_loop[frame]; } write_at += frame_count; } return(spr_all); }