Skip to content

Commit

Permalink
Merge branch 'bugy-portable-spirit-fix' into client
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-arya committed Jan 1, 2022
2 parents 701c000 + fe766a8 commit 324076d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 36 deletions.
2 changes: 1 addition & 1 deletion client/playback/src/gameworld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export default class GameWorld {

case schema.Action.TRANSFORM:
setAction();
this.bodies.alter({ id: robotID, portable: 1});
this.bodies.alter({ id: robotID, portable: 1 - body.portable});
break;

case schema.Action.MUTATE:
Expand Down
45 changes: 31 additions & 14 deletions client/visualizer/src/gamearea/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,22 @@ export default class Renderer {
}

private renderBodies(world: GameWorld, curTime: number, nextStep?: NextStep, lerpAmount?: number) {
const bodies = world.bodies
const length = bodies.length
const types = bodies.arrays.type
const teams = bodies.arrays.team
const hps = bodies.arrays.hp
const ids = bodies.arrays.id
const xs = bodies.arrays.x
const ys = bodies.arrays.y
const abilities = bodies.arrays.ability
const minY = world.minCorner.y
const maxY = world.maxCorner.y - 1
const bodies = world.bodies;
const length = bodies.length;
const types = bodies.arrays.type;
const teams = bodies.arrays.team;
const hps = bodies.arrays.hp;
const ids = bodies.arrays.id;
const xs = bodies.arrays.x;
const ys = bodies.arrays.y;
const actions = bodies.arrays.action;
const portables = bodies.arrays.portable;
const prototypes = bodies.arrays.prototype;
const minY = world.minCorner.y;
const maxY = world.maxCorner.y -1;

let nextXs: Int32Array, nextYs: Int32Array, realXs: Float32Array, realYs: Float32Array;

let nextXs: Int32Array, nextYs: Int32Array, realXs: Float32Array, realYs: Float32Array
if (nextStep && lerpAmount) {
nextXs = nextStep.bodies.arrays.x
nextYs = nextStep.bodies.arrays.y
Expand Down Expand Up @@ -254,8 +257,22 @@ export default class Renderer {
}

const renderBot = (i: number) => {
const img: HTMLImageElement = this.imgs.robots[cst.bodyTypeToString(types[i])][teams[i]]
this.drawBot(img, realXs[i], realYs[i], hps[i])

const DEFAULT: number = 0;
const PORTABLE: number = 1;
const PROTOTYPE: number = 2;
let body_status = DEFAULT
// console.log(i, bodies.length, types.length, "hhh");
// console.log(bodies[i]);
if (Boolean(portables[i])){
body_status = PORTABLE;
}
if (Boolean(prototypes[i])){
body_status = PROTOTYPE;
}
const img: HTMLImageElement = this.imgs.robots[cst.bodyTypeToString(types[i])][body_status * 2 + teams[i]];
this.drawBot(img, realXs[i], realYs[i], hps[i]);

// TODO: draw bot
this.drawSightRadii(realXs[i], realYs[i], types[i], ids[i] === this.lastSelectedID)

Expand Down
75 changes: 54 additions & 21 deletions client/visualizer/src/imageloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ export type AllImages = {
export function loadAll(config: Config, callback: (arg0: AllImages) => void) {
const dirname = "./static/img/"

const NEUTRAL: number = 0
const RED: number = 1
const BLU: number = 2
const NEUTRAL: number = 0;
const RED: number = 1;
const BLU: number = 2;
//To index additional states for buildings
const DEFAULT: number = 0;
const PORTABLE: number = 1;
const PROTOTYPE: number = 2;


function loadImage(obj, slot, path, src?): void {
const f = loadImage
Expand Down Expand Up @@ -196,24 +201,52 @@ export function loadAll(config: Config, callback: (arg0: AllImages) => void) {
}

// robot sprites
loadImage(result.robots.archon, RED, 'robots/red_archon_portable')
loadImage(result.robots.watchtower, RED, 'robots/red_watchtower')
loadImage(result.robots.builder, RED, 'robots/red_builder')
loadImage(result.robots.miner, RED, 'robots/red_miner')
loadImage(result.robots.sage, RED, 'robots/red_sage')
loadImage(result.robots.soldier, RED, 'robots/red_soldier')
loadImage(result.robots.laboratory, RED, 'robots/red_lab')

loadImage(result.robots.archon, BLU, 'robots/blue_archon_portable')
loadImage(result.robots.watchtower, BLU, 'robots/blue_watchtower')
loadImage(result.robots.builder, BLU, 'robots/blue_builder')
loadImage(result.robots.miner, BLU, 'robots/blue_miner')
loadImage(result.robots.sage, BLU, 'robots/blue_sage')
loadImage(result.robots.soldier, BLU, 'robots/blue_soldier')
loadImage(result.robots.laboratory, BLU, 'robots/blue_lab')

loadImage(result.resources, 'lead', 'resources/lead')
loadImage(result.resources, 'gold', 'resources/gold')

loadImage(result.robots.archon, DEFAULT * 2 + RED, 'robots/red_archon');
loadImage(result.robots.archon, PROTOTYPE * 2 + RED, 'robots/red_archon_prototype');
loadImage(result.robots.archon, PORTABLE * 2 + RED, 'robots/red_archon_portable');


loadImage(result.robots.watchtower, DEFAULT * 2 + RED, 'robots/red_watchtower');
loadImage(result.robots.watchtower, PROTOTYPE * 2 + RED, 'robots/red_watchtower_prototype');
loadImage(result.robots.watchtower, PORTABLE * 2 + RED, 'robots/red_watchtower_portable');


loadImage(result.robots.laboratory, DEFAULT * 2 + RED, 'robots/red_lab');
loadImage(result.robots.laboratory, PROTOTYPE * 2 + RED, 'robots/red_lab_prototype');
loadImage(result.robots.laboratory, PORTABLE * 2 + RED, 'robots/red_lab_portable');


loadImage(result.robots.builder, RED, 'robots/red_builder');
loadImage(result.robots.miner, RED, 'robots/red_miner');
loadImage(result.robots.sage, RED, 'robots/red_sage');
loadImage(result.robots.soldier, RED, 'robots/red_soldier');



loadImage(result.robots.archon, DEFAULT * 2 + BLU, 'robots/blue_archon');
loadImage(result.robots.archon, PROTOTYPE * 2 + BLU, 'robots/blue_archon_prototype');
loadImage(result.robots.archon, PORTABLE * 2 + BLU, 'robots/blue_archon_portable');

loadImage(result.robots.watchtower, DEFAULT * 2 + BLU, 'robots/blue_watchtower');
loadImage(result.robots.watchtower, PROTOTYPE * 2 + BLU, 'robots/blue_watchtower_prototype');
loadImage(result.robots.watchtower, PORTABLE * 2 + BLU, 'robots/blue_watchtower_portable');


loadImage(result.robots.laboratory, DEFAULT * 2 + BLU, 'robots/blue_lab');
loadImage(result.robots.laboratory, PROTOTYPE * 2 + BLU, 'robots/blue_lab_prototype');
loadImage(result.robots.laboratory, PORTABLE * 2 + BLU, 'robots/blue_lab_portable');


loadImage(result.robots.builder, BLU, 'robots/blue_builder');
loadImage(result.robots.miner, BLU, 'robots/blue_miner');
loadImage(result.robots.sage, BLU, 'robots/blue_sage');
loadImage(result.robots.soldier, BLU, 'robots/blue_soldier');


loadImage(result.resources, 'lead', 'resources/lead');
loadImage(result.resources, 'gold', 'resources/gold');



// loadImage(result.robots.enlightenmentCenter, NEUTRAL, 'robots/center');
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 324076d

Please sign in to comment.