{"assets":{"script":[{"Game":{"type":"game script","start":"\r\n# the biggest this number, the easier to have\r\n# an encounter while moving\r\ngame.encounterChance = 0.8\r\n\r\n# if the game is paused\r\ngame.paused = False\r\n\r\n# this is going to store the filters\r\n# currently being used in the game\r\ngame.glitchFilter = -1\r\ngame.ctrFilter = -1\r\ngame.alphaFilter = -1\r\n\r\ngame.vignettingAlpha = 0\r\n\r\n# for filters management when leaving an encounter\r\ngame.leavingEncounter = False\r\n\r\n# to store where the player was when the encounter happened\r\n# also sets the player's start position\r\ngame.playerPosition = [0,0]\r\n\r\n\r\napply_cave_filter()\r\n\r\nroom_set('Play')","loop":""}},{"Background":{"type":"object script","start":"#Background start\n\nself.sprite = sprite('background.png')\n","loop":"#Background loop\n\n"}},{"Trainer":{"type":"object script","start":"#Trainer start\n\n#how fast the player moves\nself.speed = 4\n\n# how fast the animation is going to play when the player is walking\nself.animationSpeed = 10\n\n# the direction our trainer is looking\nself.lookingDirection = 'right'\n\n# if player is idle or not (not = walking)\nself.idle = True\n\n# sets an animation\n# check the Player function for details\nchoose_animation(self, self.lookingDirection, 0)\n\n\n\n\n\nself.walkSound = sound('walk.mp3')\nset_volume(self.walkSound, 0.2)\n# to control when the sound can be played\nself.soundDelay = 10\nself.soundTimer = self.soundDelay\nself.canPlayWalkSound = False","loop":"#Trainer loop\n\n# both functions will return 1, 0, or -1\n# 1 = up/right -1 = down/left\n# vertical inputs\nvInput = (key_is_pressed('W') or key_is_pressed('arrowUp')) - (key_is_pressed('S') or key_is_pressed('arrowDown'))\n# horizontal inputs\nhInput = (key_is_pressed('D') or key_is_pressed('arrowRight')) - (key_is_pressed('A') or key_is_pressed('arrowLeft'))\n\n\n\nif game.paused == False:\n move_player(self, hInput * self.speed, vInput * self.speed)\n\n\n\n\nif self.soundTimer < self.soundDelay:\n self.soundTimer += 1\n self.canPlayWalkSound = False\nelse:\n self.canPlayWalkSound = True\n\n"}},{"CameraController":{"type":"object script","start":"#CameraController start\n\nself.z = -10\n\n# 0 to 1\n# 0 = camera stopped\n# 1 = camera has no delay to follow\nself.cameraSpeed = 0.07\n\n\n\n\n","loop":"#CameraController loop\n\nxToMove = (game.lary.x - self.x) * self.cameraSpeed\nyToMove = (game.lary.y - self.y) * self.cameraSpeed\n\nself.x += xToMove\nself.y += yToMove\n\n\n# creating camera boundaries\nif self.x > 320:\n self.x = 320\nif self.x < -320:\n self.x = -320\nif self.y > 180:\n self.y = 180\nif self.y < -180:\n self.y = -180\n\ncamera_set(self.x, self.y)"}},{"Collider":{"type":"object script","start":"#Collider start\n\n","loop":"#Collider loop\n\n"}},{"Encounter":{"type":"object script","start":"#Encounter start\n\nself.z = -10\n\n\n# to make the screen flash white\nself.white = WhiteScreen()\nself.flashTimer = 0\nself.flashDuration = 30\n\n\n# if true, the screen flashes\n# if false, applies the second filter for the encounter\nself.screenFlashing = True\n\n\n\n# to make the screen open with glitch filter\nself.glitchTimer = 0\nself.glitchDuration = 20\nself.offset = 0\n\n\n# save player position\ngame.playerPosition[0] = game.lary.x\ngame.playerPosition[1] = game.lary.y\n\n\n\n\n\n\n\nself.flashSound = sound('whiteScreen.wav')\nset_volume(self.flashSound, 0.5)\nplay_sound(self.flashSound)\n\nself.transitionSound = sound('screenChange.wav')\nset_volume(self.transitionSound, 0.1)","loop":"#Encounter loop\n\nif self.screenFlashing:\n self.flashTimer += 1\n if self.flashTimer < self.flashDuration:\n flashTime = self.flashTimer % (self.flashDuration/2)\n if flashTime < self.flashDuration/4:\n self.white.alphaFilter.alpha = flashTime/(self.flashDuration/4)\n elif flashTime < self.flashDuration/2:\n self.white.alphaFilter.alpha = 1 - (flashTime/(self.flashDuration/2))\n else:\n self.white.alphaFilter.alpha = 0\n self.screenFlashing = False\n destroy(self.white)\n apply_encounter_filter()\n apply_alpha_filter(game)\n game.alphaFilter.alpha = 0.5\n sound_play(self.transitionSound)\nelif self.glitchTimer < self.glitchDuration:\n game.glitchFilter.offset = self.offset\n self.offset = 1000 * (self.glitchTimer/self.glitchDuration)\n self.glitchTimer += 1\n game.alphaFilter.alpha = 0.5 - ((self.glitchTimer/self.glitchDuration)/2)\nelse:\n room_set('Battle')"}},{"WhiteScreen":{"type":"object script","start":"#WhiteScreen start\n\nself.alphaFilter = -1\n\nself.sprite = sprite('whiteScreen.png')\n\napply_alpha_filter(self)\n\nself.x = game.camera.x\nself.y = game.camera.y","loop":"#WhiteScreen loop\n\nself.x = game.camera.x\nself.y = game.camera.y"}},{"PlayerMonster":{"type":"object script","start":"#Monster start\n\nself.maxLife = 100\nself.life = self.maxLife\n\nself.name = 'Megg'\nself.level = 7\n\nself.attack = 10\n\nself.attacking = False\nself.attackTimer = 0\nself.timeToAttack = 30\n# to prevent more damage than expected\n# i'll set this to true when the damage was already applied to the target\nself.damageCalculated = False\n\nspriteSheet = sprite('tamago.png', 1, 5)\nanim = animation(spriteSheet, 5, 0, 4)\nset_animation(self, anim)\n\n\nself.originalX = -420\nself.originalY = -120\n\nself.x = self.originalX\nself.y = self.originalY\n\nself.scaleX = 1.3\nself.scaleY = 1.3\n\nself.lifeBar = LifeBar()\nself.lifeBar.z = 9\nself.lifeBar.sprite = sprite('playerLife.png')\nself.lifeBar.x = self.x + 620\nself.lifeBar.y = self.y - 90\nself.lifeBar.originalX = self.lifeBar.x\n\n\ninfoDisplay = self.name + ' || Lv. ' + str(self.level)\nself.nameField = text(infoDisplay, self.x + 220 , self.y - 35)\nself.nameField.fontFamily = 'helvetica'\nself.nameField.color = 'white'\nself.nameField.fontSize = 30\n\n\n\n\n\nself.attackSound = sound('attackHit.mp3')\nset_volume(self.attackSound, 0.025)","loop":"#Monster loop\n\nimport random\n\nself.lifeBar.scaleX = self.life/self.maxLife\n\nif self.attacking:\n target = game.battle.enemy\n self.attackTimer += 1\n if self.attackTimer < self.timeToAttack/4:\n self.z = 5\n self.x += (target.x - self.x - 100) * (self.attackTimer/(self.timeToAttack/4))\n self.y += (target.y - self.y - 100) * (self.attackTimer/(self.timeToAttack/4))\n elif self.attackTimer < self.timeToAttack:\n if self.damageCalculated == False:\n self.damageCalculated = True\n target.life -= random.uniform(self.attack * 0.5, self.attack * 1.5)\n shake = ScreenShaker()\n sound_play(self.attackSound)\n self.x += (self.originalX - self.x) * (self.attackTimer/self.timeToAttack)\n self.y += (self.originalY - self.y) * (self.attackTimer/self.timeToAttack)\n else:\n self.attacking = False\n self.x = self.originalX\n self.y = self.originalY\n game.readyForNextState = True\n self.damageCalculated = False\n game.battleState += 1\n self.attackTimer = 0\n self.z = 3\n\nif self.life <= 0 and game.battleState != 10:\n self.life = 0\n update_dialogue(self.name + ' has died. You have lost! :(')\n game.battleState = 10\n apply_alpha_filter(self)\n self.alphaFilter.alpha = 0.5\n game.readyForNextState = True"}},{"EnemyMonster":{"type":"object script","start":"#EnemyMonster start\n\nimport random\n\nself.attacking = False\n\nself.attacking = False\nself.attackTimer = 0\nself.timeToAttack = 30\n# to prevent more damage than expected\n# i'll set this to true when the damage was already applied to the target\nself.damageCalculated = False\n\nchosenMonster = random.randint(0,3)\nif chosenMonster == 0:\n self.name = 'Brenchy'\n self.level = random.randint(7,14)\n self.maxLife = random.randint(120,150)\n self.life = self.maxLife\n self.attack = random.randint(6,8)\n\n spriteSheet = sprite('brenchy.png', 1, 8)\n anim = animation(spriteSheet, 5, 0, 7)\n set_animation(self, anim)\n self.scaleX = 0.5\n self.scaleY = 0.5\n\nelif chosenMonster == 1:\n self.name = 'Sluci'\n self.level = random.randint(5,10)\n self.maxLife = random.randint(100,125)\n self.life = self.maxLife\n self.attack = random.randint(3,5)\n\n spriteSheet = sprite('sluci.png', 1, 3)\n anim = animation(spriteSheet, 5, 0, 2)\n set_animation(self, anim)\n\nelif chosenMonster == 2:\n self.name = 'Pumpkill'\n self.level = random.randint(1,3)\n self.maxLife = random.randint(20,45)\n self.life = self.maxLife\n self.attack = random.randint(2,4)\n\n spriteSheet = sprite('pumpkill.png', 1, 6)\n anim = animation(spriteSheet, 5, 0, 5)\n set_animation(self, anim)\n\nelif chosenMonster == 3:\n self.name = 'King Ko'\n self.level = random.randint(7,15)\n self.maxLife = random.randint(100,200)\n self.life = self.maxLife\n self.attack = random.randint(2,7)\n\n spriteSheet = sprite('kingko.png', 1, 4)\n anim = animation(spriteSheet, 5, 0, 3)\n set_animation(self, anim)\n\n\n\n\n\nself.originalX = 420\nself.originalY = 170\n\nself.x = self.originalX\nself.y = self.originalY\n\nself.lifeBar = LifeBar()\nself.lifeBar.z = 9\nself.lifeBar.sprite = sprite('enemyLife.png')\nself.lifeBar.x = self.x - 650\nself.lifeBar.y = self.y + 165\nself.lifeBar.originalX = self.lifeBar.x\n\ninfoDisplay = self.name + ' || Lv. ' + str(self.level)\nself.nameField = text(infoDisplay, -630 , self.y + 150)\nself.nameField.fontFamily = 'helvetica'\nself.nameField.color = 'white'\nself.nameField.fontSize = 30\n\n\nself.attackSound = sound('attackHit.mp3')\nset_volume(self.attackSound, 0.025)","loop":"#EnemyMonster loop\nimport random\n\nself.lifeBar.scaleX = self.life/self.maxLife\n\nif self.attacking:\n target = game.battle.player\n self.attackTimer += 1\n if self.attackTimer < self.timeToAttack/4:\n self.z = 5\n self.x += (target.x - self.x + 100) * (self.attackTimer/(self.timeToAttack/4))\n self.y += (target.y - self.y + 100) * (self.attackTimer/(self.timeToAttack/4))\n elif self.attackTimer < self.timeToAttack:\n if self.damageCalculated == False:\n self.damageCalculated = True\n target.life -= random.uniform(self.attack * 0.5, self.attack * 1.5)\n shake = ScreenShaker()\n sound_play(self.attackSound)\n self.x += (self.originalX - self.x) * (self.attackTimer/self.timeToAttack)\n self.y += (self.originalY - self.y) * (self.attackTimer/self.timeToAttack)\n else:\n self.attacking = False\n self.x = self.originalX\n self.y = self.originalY\n game.readyForNextState = True\n self.damageCalculated = False\n game.battleState = 1\n self.attackTimer = 0\n if target.life > 0:\n update_dialogue(self.name + ' has attacked you!')\n self.z = 3\n\nif self.life <= 0 and game.battleState != 9:\n self.life = 0\n update_dialogue(self.name + ' has died. You have won!')\n game.battleState = 9\n apply_alpha_filter(self)\n self.alphaFilter.alpha = 0.5\n game.readyForNextState = True"}},{"BattleController":{"type":"object script","start":"#BattleController start\n\nself.z = -10\n\n\n\nself.player = PlayerMonster()\nself.enemy = EnemyMonster()\n\n\nself.dialogue = Dialogue()\nself.dialogue.textField.text = 'A wild ' + self.enemy.name + ' has appeared!'","loop":"#BattleController loop\n\n"}},{"Dialogue":{"type":"object script","start":"#Dialogue start\n\nself.sprite = sprite('dialogueBox.png')\n\nself.z = 10\nself.y = -280\n\nself.textField = text('', self.x - 550, self.y + 20)\nself.textField.z = 11\nself.textField.color = 'white'\nself.textField.fontSize = 30\n\n","loop":"#Dialogue loop\n\n"}},{"LifeBar":{"type":"object script","start":"#LifeBar start\n\nself.scaleY = 0.5\n\n# to update its position\nself.originalX = self.x\n# left or right\nself.align = 'left'\n\n\nself.z = 8","loop":"#LifeBar loop\n\nif self.align == 'left':\n self.x = self.originalX - ((800 - (self.scaleX*800))/2)\nelif self.align == 'right':\n self.x = self.originalX + ((800 - (self.scaleX*800))/2)\n\n"}},{"ScreenShaker":{"type":"object script","start":"#Shaker start\n\n# this object shakes the screen when created, and\n# destroys itself when done.\n\nself.timer = 15\n\nself.shakeForce = 10\n\n\nself.z = -10","loop":"#Shaker loop\nimport random\n\nself.timer -= 1\n\nrandomX = random.uniform(-self.shakeForce,self.shakeForce)\nrandomY = random.uniform(-self.shakeForce,self.shakeForce)\ncamera_set(randomX, randomY)\n\nif self.timer <= 0:\n camera_set(0, 0)\n destroy(self)"}}],"room":[{"Play":{"type":"room script","start":"#Play start\n\nBackground()\ngame.lary = Trainer()\ngame.lary.x = game.playerPosition[0]\ngame.lary.y = game.playerPosition[1]\n\ngame.camera = CameraController()\n\ncreate_room_objects()\n\nreset_all_filters()\n\n\n# for leaving the encounter\nself.alphaDuration = 20\nself.alphaTimer = 0","loop":"#Play loop\n\nif game.leavingEncounter == True:\n game.paused = True\n self.alphaTimer += 1\n game.alphaFilter.alpha = self.alphaTimer/self.alphaDuration\n if self.alphaTimer > self.alphaDuration:\n game.paused = False\n game.alphaFilter.alpha = 1\n game.leavingEncounter = False"}},{"Battle":{"type":"room script","start":"#Battle start\n\ncamera_set(0,0)\n\nbackground = Background()\n\n# to control the glitch filter and put the game\n# back together\nself.glitchTimer = 0\nself.glitchDuration = 60\nself.offset = 1000\n\n\ngame.ctrFilter.vignettingAlpha = 0\n\n# to control if the effect is already done or not\nself.glitchEffectDone = False\n\n# battle components\ngame.battle = BattleController()\n\n# to control what is happening now\n# 0 - start\n# 1 - player turn\n# 2 - enemy turn\n# 9 - battle end - victory\n# 10 - battle end - defeat\ngame.battleState = 1\n#if the game is ready to change states\ngame.readyForNextState = False\n\n\n\n# for leaving the encounter\nself.alphaDuration = 20\nself.alphaTimer = 0\n\n\n\nself.battleSound = sound('battleStart.wav')\nset_volume(self.battleSound, 0.15)\n\n\nself.dashSound = sound('attackDash.mp3')\nset_volume(self.dashSound, 0.2)","loop":"#Battle loop\n\n\nif game.leavingEncounter == True:\n self.alphaTimer += 1\n game.alphaFilter.alpha = 1 - (self.alphaTimer/self.alphaDuration)\n if self.alphaTimer > self.alphaDuration:\n if game.battleState == 9:\n room_set('Play')\n else:\n room_set('Defeat')\nelse:\n if self.glitchEffectDone == False:\n if self.glitchTimer < self.glitchDuration:\n game.glitchFilter.offset = self.offset\n self.offset = 2000 - (2000 * (self.glitchTimer/self.glitchDuration))\n self.glitchTimer += 1\n game.alphaFilter.alpha = 1 * (self.glitchTimer/self.glitchDuration)\n else:\n game.glitchFilter.offset = 0\n game.alphaFilter.alpha = 1\n self.glitchEffectDone = True\n game.readyForNextState = True\n game.battleStage = 1\n play_sound(self.battleSound)\n elif game.readyForNextState == True:\n battleKey = key_was_pressed(' ') or mouse_was_pressed('left')\n\n if battleKey == True:\n game.readyForNextState = False\n\n if game.battleState == 1:\n player = game.battle.player\n update_dialogue(player.name + ' is attacking!')\n player.attacking = True\n sound_play(self.dashSound)\n elif game.battleState == 9 or game.battleState == 10:\n game.leavingEncounter = True\n\n if game.battleState == 2:\n game.readyForNextState = False\n enemy = game.battle.enemy\n update_dialogue(enemy.name + ' is attacking!')\n enemy.attacking = True\n sound_play(self.dashSound)\n\n\n\n \n\n\n"}},{"Defeat":{"type":"room script","start":"#Defeat start\n\ndefeatText = new_text('DEFEAT',-450,150)\ndefeatText.color = 'red'\ndefeatText.fontSize = 250\n\ninstructions = new_text('Press space to play again',-300,-270)\ninstructions.color = 'white'\ninstructions.fontSize = 50\n\n\n# for leaving the encounter\nself.alphaDuration = 20\nself.alphaTimer = 0\n\n\n\n","loop":"#Defeat loop\n\n\nif game.leavingEncounter == True:\n game.paused = True\n self.alphaTimer += 1\n game.alphaFilter.alpha = self.alphaTimer/self.alphaDuration\n if self.alphaTimer > self.alphaDuration:\n game.paused = False\n game.alphaFilter.alpha = 1\n game.leavingEncounter = False\n\nif game.paused == False:\n if key_was_pressed(' '):\n game.playerPosition = [0,0]\n room_set('Play')"}}],"texture":[{"background.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__PIXELPAD_ASSET__.16841.217186.background.png"}},{"rockType1.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612461200.rockType1.png"}},{"rockType2.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612461208.rockType2.png"}},{"spikes.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612461217.spikes.png"}},{"Trainer":[{"trainerUp.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612467425.trainerUp.png"}},{"trainerRight.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612467475.trainerRight.png"}},{"trainerDown.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612467485.trainerDown.png"}}]},{"whiteScreen.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612477436.whiteScreen.png"}},{"Monsters":[{"sluci.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612490140.sluci.png"}},{"tamago.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612490113.tamago.png"}},{"pumpkill.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612574930.pumpkill.png"}},{"kingko.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612574939.kingko.png"}},{"brenchy.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612490120.brenchy.png"}}]},{"dialogueBox.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612490370.dialogueBox.png"}},{"enemyLife.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612491603.enemyLife.png"}},{"playerLife.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612491609.playerLife.png"}},{"battleBg.png":{"type":"image","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612560728.battleBg.png"}}],"sound":[{"walk.mp3":{"type":"audio","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612573030.walk.mp3"}},{"whiteScreen.wav":{"type":"audio","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612573454.whiteScreen.wav"}},{"screenChange.wav":{"type":"audio","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612573583.screenChange.wav"}},{"battleStart.wav":{"type":"audio","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612573847.battleStart.wav"}},{"attackDash.mp3":{"type":"audio","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612573991.attackDash.mp3"}},{"attackHit.mp3":{"type":"audio","uri":"https://s3.us-west-1.amazonaws.com/media.pixelpad.io/__ASSET__.16841.217186.1612574011.attackHit.mp3"}}],"function":[{"Player":{"type":"function script","head":"\n\ndef move_player(trainer, xToMove, yToMove):\n # moves and animates the player\n # also checks for encounters\n previousX = trainer.x\n previousY = trainer.y\n\n move_x(trainer, xToMove)\n move_y(trainer, yToMove)\n\n xMoved = trainer.x - previousX\n yMoved = trainer.y - previousY\n\n update_animation(trainer, xMoved, yMoved)\n\n #checking for encounters\n if abs(xMoved) + abs(yMoved) != 0:\n if trainer.canPlayWalkSound == True:\n sound_play(trainer.walkSound)\n trainer.soundTimer = 0\n if calculate_encounter_chance(trainer, xMoved, yMoved) == True:\n game.paused = True\n choose_animation(trainer, trainer.lookingDirection, 0)\n Encounter()\n\n\ndef calculate_encounter_chance(trainer, xMoved, yMoved):\n # calculates if the player is having an encounter now\n # returns true if there was an encounter\n import random\n moved = xMoved + yMoved\n rolls = int(moved / trainer.speed)\n for i in range(rolls):\n chance = random.uniform(0,100)\n if chance < game.encounterChance:\n return True\n return False\n \n\ndef update_animation(trainer, xMoved, yMoved):\n # updates the player's current sprite/animation\n isIdle = trainer.idle\n animSpeed = trainer.animationSpeed\n newDirection = trainer.lookingDirection\n \n if yMoved > 0:\n newDirection = 'up'\n isIdle = False\n elif yMoved < 0: \n newDirection = 'down'\n isIdle = False\n elif xMoved > 0:\n newDirection = 'right'\n isIdle = False\n elif xMoved < 0: \n newDirection = 'left'\n isIdle = False\n else:\n animSpeed = 0\n isIdle = True\n\n if newDirection != trainer.lookingDirection or isIdle != trainer.idle:\n trainer.lookingDirection = newDirection\n trainer.idle = isIdle\n choose_animation(trainer, trainer.lookingDirection, animSpeed)\n\n\ndef sign(x):\n # this function returns the sign of a number\n # sign(-4) = -1\n # sign(-35) = -1\n # sign(5) = 1\n # sign(1.66) = 1\n from math import copysign \n return copysign(1, x) \n\ndef move_x(trainer, xToMove):\n # moves in the X axis\n step = sign(xToMove)\n for i in range(abs(xToMove)):\n trainer.x += step\n if get_collision(trainer,'Collider') or is_on_walkable_area(trainer) == False:\n trainer.x -= step\n return \n\ndef move_y(trainer, yToMove):\n # moves in the Y axis\n step = sign(yToMove)\n for i in range(abs(yToMove)):\n trainer.y += step\n if get_collision(trainer,'Collider') or is_on_walkable_area(trainer) == False:\n trainer.y -= step\n return\n \n\ndef is_on_walkable_area(trainer):\n # limiting where the trainer can walk\n if trainer.x < 878 and trainer.x > -878 and trainer.y > -460 and trainer.y < 476:\n return True\n return False\n\n\ndef choose_animation(trainer, direction, speed):\n # sets the correct animation to the trainer, with the correct speed\n if direction == 'right': \n spriteSheet = sprite('trainerRight.png',4,1)\n anim = animation(spriteSheet, speed, 0, 3)\n trainer.scaleX = 1\n elif direction == 'left': \n spriteSheet = sprite('trainerRight.png',4,1)\n anim = animation(spriteSheet, speed, 0, 3)\n trainer.scaleX = -1\n elif direction == 'up': \n spriteSheet = sprite('trainerUp.png',4,1)\n anim = animation(spriteSheet, speed, 0, 3)\n trainer.scaleX = 1\n elif direction == 'down': \n spriteSheet = sprite('trainerDown.png',4,1)\n anim = animation(spriteSheet, speed, 0, 3)\n trainer.scaleX = 1\n set_animation(trainer,anim)\n"}},{"RoomCreation":{"type":"function script","head":"\n\n\n\ndef create_room_objects():\n import random\n\n # this is the room's matrix\n # objects will be created in the room based on this matrix\n # for each position:\n # '_' = empty\n # 'o' = rock type 1 or 2 (random)\n # 'u' = spikes\n # 'x' = empty , but represents map's walls\n room = [['x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x',],\n ['x','o','o','o','_','_','_','o','_','u','u','_','u','_','_','u','u','u','u','o','o','o','_','_','_','o','_','o','_','x'],\n ['x','o','o','_','o','_','_','_','_','_','_','u','_','_','_','_','_','u','u','o','o','o','_','_','_','_','_','_','_','x'],\n ['x','o','o','_','_','_','_','_','_','_','o','_','_','u','_','_','_','o','_','o','o','o','_','o','o','_','o','_','o','x'],\n ['x','o','_','_','_','o','o','o','_','_','_','_','_','_','_','_','u','_','_','o','o','o','_','o','o','o','o','_','_','x'],\n ['x','o','_','_','_','o','o','o','_','_','_','_','_','_','_','_','_','_','_','_','o','o','_','_','_','_','_','_','o','x'],\n ['x','o','o','_','_','o','_','o','_','_','u','_','_','_','_','_','_','_','_','_','_','o','o','_','_','_','_','o','o','x'],\n ['x','o','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','o','_','_','_','_','o','_','_','_','o','x'],\n ['x','o','_','o','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','o','_','_','_','_','x'],\n ['x','o','o','o','o','_','_','_','_','u','_','_','u','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','x'],\n ['x','u','_','_','o','_','o','_','_','_','_','_','u','u','_','_','_','o','o','_','_','_','_','_','_','_','_','_','_','x'],\n ['x','_','_','_','_','_','o','_','_','_','_','_','u','_','_','_','_','o','o','o','_','_','_','_','_','_','_','_','o','x'],\n ['x','_','_','_','_','_','_','_','u','_','_','_','_','u','_','_','o','o','_','_','_','_','o','_','_','_','_','_','_','x'],\n ['x','o','_','u','_','u','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','o','x'],\n ['x','o','o','u','_','_','_','o','_','u','_','u','_','_','_','u','u','u','u','_','o','_','_','_','_','o','_','o','_','x'],\n ['x','o','o','o','o','u','o','o','u','_','u','u','_','u','_','_','_','_','u','_','_','_','o','_','o','o','o','o','o','x'],\n ['x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x','x',]]\n\n # reading the matrix and positioning each object as specified\n for j in range(len(room)):\n for i in range(len(room[j])):\n pos = room[j][i]\n if pos != '_' and pos != 'x':\n if pos == 'o':\n collider = Collider()\n rockType = random.randint(1,2)\n collider.sprite = sprite('rockType' + str(rockType) + '.png')\n elif pos == 'u':\n collider = Collider()\n collider.sprite = sprite('spikes.png')\n collider.x = -960 + (i*64) + 32\n collider.y = 540 - (j*64) - 32\n"}},{"Filters":{"type":"function script","head":"\n\n\ndef apply_cave_filter():\n\n #Configure our filter to how we want it to look.\n filterConfig = {\n \"lineWidth\" : 0,\n \"noise\": 0.1,\n \"vignetting\" : 0.6,\n \"vignettingAlpha\" : 0.75,\n \"vignettingBlur\" : 0.1,\n }\n #Set the filter to an object.\n game.ctrFilter = new_crt_filter(filterConfig)\n add_filter(game, game.ctrFilter)\n \n # storing default value\n game.vignettingAlpha = game.ctrFilter.vignettingAlpha\n\t\ndef apply_encounter_filter():\n\n #Configure our filter to how we want it to look.\n filterConfig = {\n \"slices\":5,\n \"offset\":0,\n \"direction\":0,\n \"fillMode\":0,\n \"seed\":0,\n \"average\":True,\n \"minSize\":0,\n \"sampleSize\":512,\n }\n\n #Set the filter to an object.\n game.glitchFilter = new_glitch_filter(filterConfig)\n add_filter(game, game.glitchFilter)\n\n\ndef apply_alpha_filter(obj):\n #Configure our filter to how we want it to look.\n filterConfig = {\n \"alpha\" : 1,\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1,\n \"brightness\": 1,\n \"contrast\": 1,\n \"saturation\": 1,\n \"gamma\": 1\n }\n\n #Set the filter to an object.\n obj.alphaFilter = new_adjustment_filter(filterConfig)\n add_filter(obj, obj.alphaFilter)\n\n\ndef reset_all_filters():\n game.ctrFilter.vignettingAlpha = game.vignettingAlpha\n\n if game.leavingEncounter == True:\n game.glitchFilter.offset = 0"}},{"Battling":{"type":"function script","head":"\n\ndef update_dialogue(text):\n game.battle.dialogue.textField.text = text\n\t"}}]}}