Python Combat
|
JAVASCRIPT FOR LEVEL 3. More...
Functions | |
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 | create_map () |
This function creates the arena. More... | |
function | snowman_kill () |
Kills the snowman and changes the value of snowman_killed to 1. More... | |
function | walk (r) |
This function controls the movement of warrior based on the input given. More... | |
function | check_success (code) |
This function is used for logger message of success or error. More... | |
function | print_stat () |
This function is used to show print statement in the logger. More... | |
Variables | |
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 | arena_type = 0 |
check if arena was of type 1 or 2 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 | snowman_killed = 0 |
The following var stores if info about status of snowman. 0 menas alive 1 means dead. More... | |
var | logger = document.getElementById('log') |
console | log |
JAVASCRIPT FOR LEVEL 3.
function check_success | ( | code | ) |
This function is used for logger message of success or error.
final position of warrior and number of lines is checked in this function to check if user have successfully completed task or not.
{string} | code code written by user as a string. This is used to calculate number of lines |
function create_map | ( | ) |
This function creates the arena.
There is code for two different arena we choose a random numberbetweeen 0 and 1 if number is less than 0.5 we choose arena_type 1 else arena_type 2.
For sprite of each path we again choose a randon number and if this number is greater than 0.6 we add a diamond at that point.
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 snowman_kill | ( | ) |
Kills the snowman and changes the value of snowman_killed to 1.
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 |
var arena_type = 0 |
check if arena was of type 1 or 2
speed_show innerHTML = speed_dict[speed] |
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 snowman_killed = 0 |
The following var stores if info about status of snowman.
0 menas alive
1 means dead.
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.