1 decade ago by farman
Medallion is the puzzle game I'm currently developing.
The core game mechanic revolves around flipping the character to his opposite position over the line of symmetry.
Right now I am grabbing the width and height of the screen and calculating the player's distance from the line of symmetry, throwing it into an Absolute Value algorithm, and tossing him on the other side of the line. This is done in code like this.
This works fine when I keep the levels the size of the game screen. Each tile is 16px and the screen is 24x16 tiles.
The problem is that I am planning on making levels later in the game where the map is bigger and the screen pans. I&
Also the documentation lists
Is (0,0) the top left corner of the map or the camera screen? Is there anyway to access the coordinates based on their location within the camera screen?
Thank you,
Tom
Farman.Farout
The core game mechanic revolves around flipping the character to his opposite position over the line of symmetry.
Right now I am grabbing the width and height of the screen and calculating the player's distance from the line of symmetry, throwing it into an Absolute Value algorithm, and tossing him on the other side of the line. This is done in code like this.
if (this.pos.y > this.mapSizeX) { this.shadowY = this.mapSizeX - this.distanceFromMiddleX - 16; } else { this.shadowY = this.mapSizeX + this.distanceFromMiddleX - 16; } //fip vars this.mapSizeY = (ig.game.collisionMap.width * 16) / 2; this.mapSizeX = (ig.game.collisionMap.height * 16) / 2; this.distanceFromMiddleY = Math.abs(this.mapSizeY - this.pos.x); this.distanceFromMiddleX = Math.abs(this.mapSizeX - this.pos.y); //flip change Y if (ig.input.released('Y') && this.vel.x === 0 && this.vel.y === 0 && ig.game.canFlipY === true) { var shadowMan = ig.game.getEntitiesByType(EntityShadowMan)[0]; if (shadowMan.checkToSeeIfYouCan()) { ig.game.spawnEntity(EntityMothMarker, this.pos.x, this.pos.y - 7); ig.game.shadowJump.play(); this.pos.x = this.shadowX; } else if (!shadowMan.checkToSeeIfYouCan()) { ig.game.youCannotDoThat.play(); } }
This works fine when I keep the levels the size of the game screen. Each tile is 16px and the screen is 24x16 tiles.
The problem is that I am planning on making levels later in the game where the map is bigger and the screen pans. I&
039;ve searched through our documentation for Impact and I can't find a solution. I need to eliminate my dependence on #ig.game.collisionMap.width
and height
.Also the documentation lists
pos.x
and pos.y
as "The entity's position in the game world."Is (0,0) the top left corner of the map or the camera screen? Is there anyway to access the coordinates based on their location within the camera screen?
Thank you,
Tom
Farman.Farout