Python Combat
|
JAVASCRIPT FOR LEVEL 5. More...
Functions | |
function | create_arena () |
This function is used to restore the values of the global variables after reload. More... | |
function | speedup () |
This function is bind to the increase button it decreases the value of var speed so that animation time is less and hence speed increases finally. More... | |
function | speeddown () |
This function is bind to the decrease button it increases the value of var speed so that animation time is more and hence speed decreases finally. More... | |
function | weapon () |
This function checks if the gem is collected or not in order. More... | |
function | check_success () |
The function checks if the players code is correct or not. More... | |
function | add_weapon (px, py, n) |
This function is used to add gems on the arena using the location parameters like px, py provided from brython. More... | |
function | walk (r) |
This function controls the movement of warrior based on the input given. More... | |
function | print_stat () |
This function is used to show print statement in the logger. More... | |
Variables | |
var | gem_found = [false, false, false, false, false] |
The list stores info about which gems are collected. More... | |
var | pos_x = 0 |
stores the X-coordinate of warrior More... | |
var | pos_y = 0 |
stores the Y-coordinate of warrior More... | |
var | reloaded = true |
check if reloading was done before or not More... | |
var | insequence = true |
it stores true if the gems are collected in sequence else false. More... | |
var | id_order = [] |
it stores the values as the gems are added to the arena. More... | |
var | index = 0 |
stores the index upto which the gems found are checked while checking in animate part of jquery. This is required since jquery implements animation through queue. More... | |
var | speed = 500 |
For the animation speed of the player. More... | |
speed_dict = {250 : "fast", 500 : "medium", "750" : "slow"} | |
maps speeds in milliseconds to the name corresponding to them. More... | |
const | speed_show = document.getElementById("speed_") |
The element in which we have to show speed. More... | |
speed_show | innerHTML = speed_dict[speed] |
var | logger = document.getElementById('log') |
console | log |
JAVASCRIPT FOR LEVEL 5.
function add_weapon | ( | px, | |
py, | |||
n | |||
) |
This function is used to add gems on the arena using the location parameters like px, py provided from brython.
n is used to indicate the nth gem added.
{*} | px |
{*} | py |
{*} | n |
function check_success | ( | ) |
The function checks if the players code is correct or not.
If it is correct then it prints the message and if it is not, it will reload page after 5 second.
function create_arena | ( | ) |
This function is used to restore the values of the global variables after reload.
function print_stat | ( | ) |
This function is used to show print statement in the logger.
This function is implemented by overloading console.log function to show print statements on logger as well.
function speeddown | ( | ) |
This function is bind to the decrease button it increases the value of var speed so that animation time is more and hence speed decreases finally.
function speedup | ( | ) |
This function is bind to the increase button it decreases the value of var speed so that animation time is less and hence speed increases finally.
function walk | ( | r | ) |
This function controls the movement of warrior based on the input given.
Exception handling is also done in this function as while moving if warrior steps out of arena alert box is shown
{int} | r integer determining direction of traversal. 1 => move_up, 2=>move_down() 3 => move_right() 4=> move_left |
function weapon | ( | ) |
This function checks if the gem is collected or not in order.
It sets value of insequence to be true if gems are collected in correct order.
var gem_found = [false, false, false, false, false] |
The list stores info about which gems are collected.
var id_order = [] |
it stores the values as the gems are added to the arena.
var index = 0 |
stores the index upto which the gems found are checked while checking in animate part of jquery.
This is required since jquery implements animation through queue.
speed_show innerHTML = speed_dict[speed] |
var insequence = true |
it stores true if the gems are collected in sequence else false.
console log |
var logger = document.getElementById('log') |
var pos_x = 0 |
stores the X-coordinate of warrior
var pos_y = 0 |
stores the Y-coordinate of warrior
var reloaded = true |
check if reloading was done before or not
var speed = 500 |
For the animation speed of the player.
speed_dict = {250 : "fast", 500 : "medium", "750" : "slow"} |
maps speeds in milliseconds to the name corresponding to them.
const speed_show = document.getElementById("speed_") |
The element in which we have to show speed.