Grid item height tweaking
This commit is contained in:
		| @@ -1,8 +1,9 @@ | ||||
| import {Color, Point, Size} from "./engine/datatypes.ts"; | ||||
| import {Color, Point, Rect, Size} from "./engine/datatypes.ts"; | ||||
| import {D} from "./engine/public.ts"; | ||||
|  | ||||
| export const FLOOR_CELL_SIZE: Size = new Size(48, 48) | ||||
| export const FLOOR_CELL_SIZE: Size = new Size(40, 40) | ||||
| export const CEILING_CELL_SIZE: Size = new Size(52, 52) | ||||
| export const HEIGHT_IN_FEET = 12; | ||||
| export const CENTER = new Point(192, 192); | ||||
| export const MOULDING_SZ = new Size(1, 1); | ||||
|  | ||||
| @@ -27,6 +28,10 @@ export class GridArt { | ||||
|     this.#ceilingBr = at.offset(new Point(0.5, 0.5)).scale(CEILING_CELL_SIZE).offset(CENTER); | ||||
|   } | ||||
|  | ||||
|   get floorRect(): Rect { | ||||
|     return new Rect(this.#floorTl, this.#floorBr.subtract(this.#floorTl)) | ||||
|   } | ||||
|  | ||||
|   drawFloor(color: Color) { | ||||
|     D.fillRect(this.#floorTl, this.#floorBr.subtract(this.#floorTl), color); | ||||
|   } | ||||
| @@ -122,6 +127,14 @@ export class GridArt { | ||||
|   drawCeiling(color: Color) { | ||||
|     D.fillRect(this.#ceilingTl, this.#ceilingBr.subtract(this.#ceilingTl), color); | ||||
|   } | ||||
|  | ||||
|   project(z: number): Point { | ||||
|     let z2 = z / HEIGHT_IN_FEET; | ||||
|     return new Point( | ||||
|       lerp(z2, this.#floorCenter.x, this.#ceilingCenter.x), | ||||
|       lerp(z2, this.#floorCenter.y, this.#ceilingCenter.y), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
| let lerp = (amt: number, x: number, y: number) => { | ||||
|   | ||||
| @@ -151,18 +151,11 @@ export class HuntMode { | ||||
|     const OFFSET_AIR = 0; | ||||
|     const OFFSET_TOP = 256; | ||||
|     const OFFSET_TOP_OF_TOP = 512; | ||||
|     const cellSizeFloor = new Size(48, 48); | ||||
|     const cellSizeCeiling = new Size(52, 52); | ||||
|  | ||||
|     const floorZone = offsetInCells.scale(cellSizeFloor).offset(new Point(192, 192)); | ||||
|  | ||||
|     const gridArt = new GridArt(offsetInCells); | ||||
|  | ||||
|     let cellData = this.map.get(mapPosition) | ||||
|  | ||||
|     let cellTopLeft = floorZone.offset(new Size(-cellSizeFloor.w / 2, -cellSizeCeiling.h / 2)); | ||||
|     let cellSize = FLOOR_CELL_SIZE; | ||||
|  | ||||
|     this.drawpile.add( | ||||
|       OFFSET_UNDER_FLOOR, | ||||
|       () => { | ||||
| @@ -198,7 +191,7 @@ export class HuntMode { | ||||
|         } | ||||
|          */ | ||||
|       }, | ||||
|       new Rect(cellTopLeft, cellSize), | ||||
|       gridArt.floorRect, | ||||
|       cost != null && cost <= getPlayerProgress().getBlood(), | ||||
|       () => { | ||||
|         if (cost != null) { | ||||
| @@ -247,12 +240,10 @@ export class HuntMode { | ||||
|     if (pickup != null) { | ||||
|       let statIndex = ALL_STATS.indexOf(pickup as Stat); | ||||
|       if (statIndex != -1) { | ||||
|         let extraXOffset = 0; // Math.cos(this.frame / 80 + mapPosition.x + mapPosition.y) * 1; | ||||
|         let extraYOffset = Math.sin(this.frame / 50 + mapPosition.x * 2 + mapPosition.y * 0.75) * 6; | ||||
|         this.drawpile.add(OFFSET_AIR, () => { | ||||
|           D.drawSprite( | ||||
|             sprStatPickup, | ||||
|             floorZone.offset(new Point(extraXOffset, extraYOffset)), | ||||
|             gridArt.project(5), | ||||
|             statIndex, | ||||
|             { | ||||
|               xScale: 2, | ||||
| @@ -266,7 +257,7 @@ export class HuntMode { | ||||
|         this.drawpile.add(OFFSET_AIR, () => { | ||||
|           D.drawSprite( | ||||
|             sprResourcePickup, | ||||
|             floorZone.offset(new Point(0, -16)), | ||||
|             gridArt.project(0.0).offset(new Point(0, -16)), | ||||
|             0, | ||||
|             { | ||||
|               xScale: 2, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user