How to use num method in wpt

Best JavaScript code snippet using wpt

barriers.js

Source:barriers.js Github

copy

Full Screen

1//barriers.js2//Master Copy - Space Invaders II3//GAM1004//Fall, 20205//Major : Junsu Jang, Minor : Daehyeon Kim6//“All content © 2020 DigiPen (USA) Corporation, all rights reserved.”7class barrier {8 constructor(x, y) {//Input barrier x, y9 this.x = x;10 this.y = y;11 this.up_damaged = 0;//Current situation of middle side damage from top12 this.down_damaged = 0;//Current situation of middle side damage from bottom13 this.right_up_damaged = 0;//Current situation of right side damage from top14 this.right_down_damaged = 0;//Current situation of right side damage from bottom15 this.left_up_damaged = 0;//Current situation of left side damage from top16 this.left_down_damaged = 0;//Current situation of left side damage from bottom17 this.image_size = 16;18 this.left_damage_max = 11;19 this.right_damage_max = 11;20 this.middle_damage_max = 9;21 this.left_image_1 = image_barrier_left[0];//Top of left side barrier image22 this.left_image_2 = image_barrier_square[0];//Middle of left side barrier image23 this.left_image_3 = image_barrier_square[0];//Bottom of left side barrier image24 this.right_image_1 = image_barrier_right[0];//Top of right side barrier image25 this.right_image_2 = image_barrier_square[0];//Middle of right side barrier image26 this.right_image_3 = image_barrier_square[0];//Bottom of right side barrier image27 this.middle_image_1 = image_barrier_square[0];//Top of middle side barrier image28 this.middle_image_2 = image_barrier_square[0];//Bottom of middle sode barrier image29 }30 generate() {//Draw barrier31 var barrier_left_1 = {//Designate top of left side position32 x: this.x - this.image_size,33 y: this.y - this.image_size34 },35 barrier_left_2 = {//Designate middle of left side position36 x: this.x - this.image_size,37 y: this.y38 },39 barrier_left_3 = {//Designate bottom of left side position40 x: this.x - this.image_size,41 y: this.y + this.image_size42 },43 barrier_right_1 = {//Designate top of right side position44 x: this.x + this.image_size,45 y: this.y - this.image_size46 },47 barrier_right_2 = {//Designate middle of right side position48 x: this.x + this.image_size,49 y: this.y50 },51 barrier_right_3 = {//Designate bottom of right side position52 x: this.x + this.image_size,53 y: this.y + this.image_size54 },55 barrier_midle_1 = {//Designate top of middle side position56 x: this.x,57 y: this.y - this.image_size58 },59 barrier_midle_2 = {//Designate bottom of middle side position60 x: this.x,61 y: this.y62 },63 barrier_midle_3 = {//Designate tail of bottom of middle side position64 x: this.x,65 y: this.y + this.image_size66 };67 push();68 imageMode(CENTER);69 image(this.left_image_1, barrier_left_1.x, barrier_left_1.y, this.image_size, this.image_size);70 image(this.left_image_2, barrier_left_2.x, barrier_left_2.y, this.image_size, this.image_size);71 image(this.left_image_3, barrier_left_3.x, barrier_left_3.y, this.image_size, this.image_size);72 image(this.right_image_1, barrier_right_1.x, barrier_right_1.y, this.image_size, this.image_size);73 image(this.right_image_2, barrier_right_2.x, barrier_right_2.y, this.image_size, this.image_size);74 image(this.right_image_3, barrier_right_3.x, barrier_right_3.y, this.image_size, this.image_size);75 image(this.middle_image_1, barrier_midle_1.x, barrier_midle_1.y, this.image_size, this.image_size);76 image(this.middle_image_2, barrier_midle_2.x, barrier_midle_2.y, this.image_size, this.image_size);77 if (this.down_damaged == 0 && this.up_damaged != this.middle_damage_max) {78 image(image_barrier_bottom_edge, barrier_midle_3.x, barrier_midle_3.y, this.image_size, this.image_size);79 }80 pop();81 }82 update() {83 if(this.left_up_damaged + this.left_down_damaged >= this.left_damage_max){//Prevent damage beyond the limit.84 this.left_up_damaged = this.left_damage_max;85 this.left_down_damaged = 0;86 }87 if(this.right_up_damaged + this.right_down_damaged >= this.right_damage_max){88 this.right_up_damaged = this.right_damage_max;89 this.right_down_damaged = 0;90 }91 if(this.up_damaged + this.down_damaged >= this.middle_damage_max){92 this.up_damaged = this.middle_damage_max;93 this.down_damaged = 0;94 }95var square_image_num = [//Number of square image by damage96 [0, 5, 9, 12, 14, 15],//horizontal direction is down_damaged97 [1, 6, 10, 13, 15],98 [2, 7, 11, 15],99 [3, 8, 15],100 [4, 15],101 [15]102 ];//vertical direction is up_damaged103 var left_tri_image_num = [//Number of left_triangle image by damage104 [0, 3, 5, 6],105 [1, 4, 6],106 [2, 6],107 [6]108 ];109 var right_tri_image_num = [//Number of right_triangle image by damage110 [0, 3, 5, 6],111 [1, 4, 6],112 [2, 6],113 [6]114 ];115var middle_barrier_image = [ //up_damaged116 [ //down_damaged117 [image_barrier_square[square_image_num[0][0]]/*Top*/, image_barrier_square[square_image_num[0][0]]]/*Bottom*/,118 [image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],119 [image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],120 [image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],121 [image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],122 [image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],123 [image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],124 [image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],125 [image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],126 [image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],127 ],128 [129 [image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][0]]],130 [image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][1]]],131 [image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][2]]],132 [image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][3]]],133 [image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][4]]],134 [image_barrier_square[square_image_num[1][1]], image_barrier_square[square_image_num[0][5]]],135 [image_barrier_square[square_image_num[1][2]], image_barrier_square[square_image_num[0][5]]],136 [image_barrier_square[square_image_num[1][3]], image_barrier_square[square_image_num[0][5]]],137 [image_barrier_square[square_image_num[1][4]], image_barrier_square[square_image_num[0][5]]],138 ],139 [140 [image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][0]]],141 [image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][1]]],142 [image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][2]]],143 [image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][3]]],144 [image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][4]]],145 [image_barrier_square[square_image_num[2][1]], image_barrier_square[square_image_num[0][5]]],146 [image_barrier_square[square_image_num[2][2]], image_barrier_square[square_image_num[0][5]]],147 [image_barrier_square[square_image_num[2][3]], image_barrier_square[square_image_num[0][5]]],148 ],149 [150 [image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][0]]],151 [image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][1]]],152 [image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][2]]],153 [image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][3]]],154 [image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][4]]],155 [image_barrier_square[square_image_num[3][1]], image_barrier_square[square_image_num[0][5]]],156 [image_barrier_square[square_image_num[3][2]], image_barrier_square[square_image_num[0][5]]],157 ],158 [159 [image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][0]]],160 [image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][1]]],161 [image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][2]]],162 [image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][3]]],163 [image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][4]]],164 [image_barrier_square[square_image_num[4][1]], image_barrier_square[square_image_num[0][5]]],165 ],166 [167 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][0]]],168 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][1]]],169 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][2]]],170 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][3]]],171 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][4]]],172 ],173 [174 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][0]]],175 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][1]]],176 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][2]]],177 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][3]]],178 ],179 [180 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][0]]],181 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][1]]],182 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][2]]],183 ],184 [185 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[4][0]]],186 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[4][1]]],187 ],188 [189 [image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[5][0]]],190 ]191 ];192 var left_barrier_image = [ //up_damaged193 [ //down_damaged194 [image_barrier_left[left_tri_image_num[0][0]]/*Top*/, image_barrier_square[square_image_num[0][0]]/*Middle*/, image_barrier_square[square_image_num[0][0]]]/*Bottom*/,195 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],196 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],197 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],198 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],199 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],200 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],201 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],202 [image_barrier_left[left_tri_image_num[0][0]], image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],203 [image_barrier_left[left_tri_image_num[0][1]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],204 [image_barrier_left[left_tri_image_num[0][2]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],205 [image_barrier_left[left_tri_image_num[0][3]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],206 ],207 [208 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][0]]],209 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],210 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],211 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],212 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],213 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],214 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],215 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],216 [image_barrier_left[left_tri_image_num[1][0]], image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],217 [image_barrier_left[left_tri_image_num[1][1]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],218 [image_barrier_left[left_tri_image_num[1][2]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],219 ],220 [221 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][0]]],222 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],223 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],224 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],225 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],226 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],227 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],228 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],229 [image_barrier_left[left_tri_image_num[2][0]], image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],230 [image_barrier_left[left_tri_image_num[2][1]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],231 ],232 [233 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][0]]],234 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][1]]],235 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][2]]],236 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][3]]],237 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][4]]],238 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][1]], image_barrier_square[square_image_num[0][5]]],239 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][2]], image_barrier_square[square_image_num[0][5]]],240 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][3]], image_barrier_square[square_image_num[0][5]]],241 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[1][4]], image_barrier_square[square_image_num[0][5]]],242 ],243 [244 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][0]]],245 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][1]]],246 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][2]]],247 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][3]]],248 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][4]]],249 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][1]], image_barrier_square[square_image_num[0][5]]],250 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][2]], image_barrier_square[square_image_num[0][5]]],251 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[2][3]], image_barrier_square[square_image_num[0][5]]],252 ],253 [254 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][0]]],255 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][1]]],256 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][2]]],257 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][3]]],258 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][4]]],259 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][1]], image_barrier_square[square_image_num[0][5]]],260 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[3][2]], image_barrier_square[square_image_num[0][5]]],261 ],262 [263 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][0]]],264 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][1]]],265 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][2]]],266 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][3]]],267 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][4]]],268 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[4][1]], image_barrier_square[square_image_num[0][5]]],269 ],270 [271 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][0]]],272 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][1]]],273 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][2]]],274 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][3]]],275 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][4]]],276 ],277 [278 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][0]]],279 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][1]]],280 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][2]]],281 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][3]]],282 ],283 [284 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][0]]],285 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][1]]],286 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][2]]],287 ],288 [289 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[4][0]]],290 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[4][1]]],291 ],292 [293 [image_barrier_left[left_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[5][0]]],294 ],295 ];296var right_barrier_image = [ //up_damaged297 [ //down_damaged298 [image_barrier_right[right_tri_image_num[0][0]]/*Top*/, image_barrier_square[square_image_num[0][0]]/*Middle*/, image_barrier_square[square_image_num[0][0]]]/*Bottom*/,299 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],300 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],301 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],302 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],303 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],304 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],305 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],306 [image_barrier_right[right_tri_image_num[0][0]], image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],307 [image_barrier_right[right_tri_image_num[0][1]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],308 [image_barrier_right[right_tri_image_num[0][2]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],309 [image_barrier_right[right_tri_image_num[0][3]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],310 ],311 [312 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][0]]],313 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],314 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],315 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],316 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],317 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],318 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],319 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],320 [image_barrier_right[right_tri_image_num[1][0]], image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],321 [image_barrier_right[right_tri_image_num[1][1]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],322 [image_barrier_right[right_tri_image_num[1][2]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],323 ],324 [325 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][0]]],326 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][1]]],327 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][2]]],328 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][3]]],329 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][0]], image_barrier_square[square_image_num[0][4]]],330 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][1]], image_barrier_square[square_image_num[0][5]]],331 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][2]], image_barrier_square[square_image_num[0][5]]],332 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][3]], image_barrier_square[square_image_num[0][5]]],333 [image_barrier_right[right_tri_image_num[2][0]], image_barrier_square[square_image_num[0][4]], image_barrier_square[square_image_num[0][5]]],334 [image_barrier_right[right_tri_image_num[2][1]], image_barrier_square[square_image_num[0][5]], image_barrier_square[square_image_num[0][5]]],335 ],336 [337 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][0]]],338 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][1]]],339 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][2]]],340 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][3]]],341 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][0]], image_barrier_square[square_image_num[0][4]]],342 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][1]], image_barrier_square[square_image_num[0][5]]],343 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][2]], image_barrier_square[square_image_num[0][5]]],344 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][3]], image_barrier_square[square_image_num[0][5]]],345 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[1][4]], image_barrier_square[square_image_num[0][5]]],346 ],347 [348 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][0]]],349 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][1]]],350 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][2]]],351 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][3]]],352 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][0]], image_barrier_square[square_image_num[0][4]]],353 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][1]], image_barrier_square[square_image_num[0][5]]],354 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][2]], image_barrier_square[square_image_num[0][5]]],355 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[2][3]], image_barrier_square[square_image_num[0][5]]],356 ],357 [358 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][0]]],359 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][1]]],360 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][2]]],361 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][3]]],362 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][0]], image_barrier_square[square_image_num[0][4]]],363 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][1]], image_barrier_square[square_image_num[0][5]]],364 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[3][2]], image_barrier_square[square_image_num[0][5]]],365 ],366 [367 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][0]]],368 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][1]]],369 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][2]]],370 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][3]]],371 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[4][0]], image_barrier_square[square_image_num[0][4]]],372 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[4][1]], image_barrier_square[square_image_num[0][5]]],373 ],374 [375 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][0]]],376 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][1]]],377 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][2]]],378 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][3]]],379 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[1][4]]],380 ],381 [382 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][0]]],383 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][1]]],384 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][2]]],385 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[2][3]]],386 ],387 [388 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][0]]],389 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][1]]],390 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[3][2]]],391 ],392 [393 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[4][0]]],394 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[4][1]]],395 ],396 [397 [image_barrier_right[right_tri_image_num[3][0]], image_barrier_square[square_image_num[5][0]], image_barrier_square[square_image_num[5][0]]],398 ],399 ];400 this.middle_image_1 = middle_barrier_image[this.up_damaged][this.down_damaged][0];401 this.middle_image_2 = middle_barrier_image[this.up_damaged][this.down_damaged][1];402 this.left_image_1 = left_barrier_image[this.left_up_damaged][this.left_down_damaged][0];403 this.left_image_2 = left_barrier_image[this.left_up_damaged][this.left_down_damaged][1];404 this.left_image_3 = left_barrier_image[this.left_up_damaged][this.left_down_damaged][2];405 this.right_image_1 = right_barrier_image[this.right_up_damaged][this.right_down_damaged][0];406 this.right_image_2 = right_barrier_image[this.right_up_damaged][this.right_down_damaged][1];407 this.right_image_3 = right_barrier_image[this.right_up_damaged][this.right_down_damaged][2];408 }409 crash_effect(a){//Effect of crash when a bullet collide with a barrier it'll work410 mx = a.bullet[0].position_x411 my = a.bullet[0].position_y412 a.bullet[0].bullet_break = 1;//bullet_break is 1 bullet will deleted413 monsterBulletEffectTimer = frameCount;414 }415 m_hitRange(object, currentlevel) {//Check monster bullet position and if it hits barrier, barrier has 1 up damage. 416 var left_x = this.x - this.image_size;417 var right_x = this.x + this.image_size;418 var Y = this.y;419 var object_size = 16;420 if (object.position_x < left_x + this.image_size / 2 && object.position_x >= left_x - this.image_size / 2 ) {421 this.monster_object_status = 1;422 }423 if (object.position_x <= right_x + this.image_size / 2 && object.position_x > right_x - this.image_size / 2 ) {424 this.monster_object_status = 3;425 }426 if (object.position_x <= this.x + this.image_size / 2 && object.position_x >= this.x - this.image_size / 2 ) {427 this.monster_object_status = 2;428 } //Check left, right, and middle429 switch (this.monster_object_status) {430 case 1://Collision range according to damage and position431 if (this.left_up_damaged < 3 ) {432 Y = this.y - object_size;433 } else if (this.left_up_damaged < 7) {434 Y = this.y - object_size / 2;435 } else if (this.left_up_damaged < 11) {436 Y = this.y + object_size / 2;437 }438 if (object.position_y >= Y && object.position_y <= Y + this.image_size / 2 && (this.left_up_damaged + this.left_down_damaged < 11)) {439 this.crash_effect(currentlevel)440 this.left_up_damaged++;441 this.monster_object_status = 0;442 }443 444 break;445 case 2:446 if (this.up_damaged < 4) {447 Y = this.y - object_size - object_size / 2;448 } else if (this.up_damaged < 8) {449 Y = this.y - object_size / 2;450 } else if (this.up_damaged < 9) {451 Y = this.y + object_size / 2;452 }453 if (object.position_y >= Y && object.position_y <= Y + this.image_size / 2 && (this.up_damaged + this.down_damaged < 9)) {454 this.crash_effect(currentlevel)455 this.up_damaged++;456 this.monster_object_status = 0;457 }458 break;459 case 3:460 if (this.right_up_damaged < 3) {461 Y = this.y - object_size;462 } else if (this.right_up_damaged < 7) {463 Y = this.y - object_size / 2;464 } else if (this.right_up_damaged < 11) {465 Y = this.y + object_size / 2;466 }467 if (object.position_y >= Y && object.position_y <= Y + this.image_size / 2 && (this.right_up_damaged + this.right_down_damaged < 11)) {468 this.crash_effect(currentlevel)469 this.right_up_damaged++;470 this.monster_object_status = 0;471 }472 break;473 }474}475 p_hitRange(object, currentlevel) {//Check player bullet position and if it hits barrier, barrier has 1 down damage. 476 var left_x = this.x - this.image_size;477 var right_x = this.x + this.image_size;478 var Y = this.y;479 var object_size = 16;480 if (object.position_x < left_x + this.image_size / 2 && object.position_x >= left_x - this.image_size / 2 ) {481 this.player_object_status = 1;482 }483 if (object.position_x <= right_x + this.image_size / 2 && object.position_x > right_x - this.image_size / 2 ) {484 this.player_object_status = 3;485 }486 if (object.position_x <= this.x + this.image_size / 2 && object.position_x >= this.x - this.image_size / 2 ) {487 this.player_object_status = 2;488 }//Check left, right, and middle489 switch (this.player_object_status) {490 case 1://collision range according to damage and position491 if (this.left_down_damaged < 3) {492 Y = this.y + object_size + object_size / 2;493 } else if (this.left_down_damaged < 7) {494 Y = this.y + object_size / 2;495 } else if (this.left_down_damaged < 11) {496 Y = this.y - object_size / 2;497 }498 if (object.position_y >= Y - this.image_size / 2 && object.position_y <= Y && (this.left_up_damaged + this.left_down_damaged < 11)) {499 bullet_removed(attackArray)500 this.left_down_damaged++;501 this.player_object_status = 0;502 }503 break;504 case 2:505 if (this.down_damaged < 5) {506 Y = this.y + object_size / 2;507 } else if (this.down_damaged < 9) {508 Y = this.y - object_size / 2;509 }510 if (object.position_y >= Y - this.image_size / 2 && object.position_y <= Y && (this.up_damaged + this.down_damaged < 9)) {511 bullet_removed(attackArray);512 this.down_damaged++;513 this.player_object_status = 0;514 }515 break;516 case 3:517 if (this.right_down_damaged < 3) {518 Y = this.y + object_size + object_size / 2;519 } else if (this.right_down_damaged < 7) {520 Y = this.y + object_size / 2;521 } else if (this.right_down_damaged < 11) {522 Y = this.y - object_size / 2;523 }524 if (object.position_y >= Y - this.image_size / 2 && object.position_y <= Y && (this.right_up_damaged + this.right_down_damaged < 11)) {525 bullet_removed(attackArray)526 this.right_down_damaged++;527 this.player_object_status = 0;528 }529 break;530 }531 }532 monsterCollision(object){//When a monster collide with a barrier barrier has damage533 var barrier_range = {534 left_bar : {535 right_x : this.x - this.image_size+this.image_size/2,536 left_x : this.x - this.image_size-this.image_size/2537 },538 right_bar : {539 right_x : this.x + this.image_size+this.image_size/2,540 left_x : this.x + this.image_size-this.image_size/2541 },542 hor_middle_bar : {543 right_x : this.x + this.image_size/2,544 left_x : this.x - this.image_size/2545 },546 up_bar : {547 up_y : this.y - this.image_size - this.image_size/2,548 down_y : this.y - this.image_size + this.image_size/2549 },550 down_bar : {551 up_y : this.y + this.image_size - this.image_size/2,552 down_y : this.y + this.image_size + this.image_size/2553 },554 ver_middle_bar : {555 up_y : this.y - this.image_size/2,556 down_y : this.y + this.image_size/2557 }558 }559 var object_size = 14;560 var object_range = {561 object_right_x : object.position_x+ object_size/2,562 object_left_x : object.position_x-object_size/2,563 object_down_y : object.position_y+object_size/2,564 object_up_y : object.position_y-object_size/2565 }566 if(collision(object_range,barrier_range.left_bar,barrier_range.up_bar) && this.left_up_damaged<3){567 this.left_up_damaged = 3;568 569 } if(collision(object_range,barrier_range.left_bar,barrier_range.ver_middle_bar) && this.left_up_damaged<7){570 this.left_up_damaged = 7;571 } if(collision(object_range,barrier_range.left_bar,barrier_range.down_bar) && this.left_up_damaged<11){572 this.left_up_damaged = 11;573 }574 if(collision(object_range,barrier_range.right_bar,barrier_range.up_bar) && this.right_up_damaged<3){575 this.right_up_damaged = 3;576 577 } if(collision(object_range,barrier_range.right_bar,barrier_range.ver_middle_bar) && this.right_up_damaged<7){578 this.right_up_damaged = 7;579 } if(collision(object_range,barrier_range.right_bar,barrier_range.down_bar) && this.right_up_damaged<11){580 this.right_up_damaged = 11;581 }582 if(collision(object_range,barrier_range.hor_middle_bar,barrier_range.up_bar) && this.up_damaged<5){583 584 this.up_damaged = 5;585 586 } if(collision(object_range,barrier_range.hor_middle_bar,barrier_range.ver_middle_bar) && this.up_damaged<9){587 this.up_damaged = 9;588 }589 }590}591function collision(object,barr_horsec,barr_versec){//Collision range592 if(object.object_right_x>=barr_horsec.left_x && object.object_left_x <= barr_horsec.right_x && object.object_up_y<=barr_versec.down_y && object.object_down_y>=barr_versec.up_y){593 return true;594 }595 return false;...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1$(function() {2 let num_1 = '',3 num_2 = '',4 answer = '';5 push_num = [],6 cal = '',7 calculation = false,8 memo_num = 0,9 sign = false,10 key_1 = false,11 key_2 = false,12 dot_key = false,13 dot_key_1 = false;1415 $('#minus').on('click', function () {16 if (sign == true) {17 sign = false;18 } else {19 sign = true;20 }21 });2223 $('.number').on('click', function () {2425 $('#minus').text('-');2627 push_num.push($(this).text());2829 let last = push_num[push_num.length-1];30 if (last == '-') {31 if (push_num[0] == '-') {32 push_num[0] = '0';33 } else {34 let result_minus = $.inArray('-',push_num);35 delete push_num[result_minus];36 }37 }3839 if (key_1 == false) {40 if (last == '0') {41 delete push_num[push_num.length-1];42 if (key_2 == false) {43 push_num[0] = '0';44 key_2 = true;45 }46 } else if (last == '-') {47 key_1 = false;48 } else {49 key_1 = true;50 }51 }5253 if (key_1 == true) {54 if (push_num.length >= 2) {55 if (last == '.') {56 dot_key_1 = true;57 }58 if (dot_key_1 == false) {59 dot_key_1 = true;60 if (push_num[0] == '0') {61 push_num.shift();62 }63 }64 }65 }6667 if (dot_key == true) {68 if (push_num[push_num.length-1] == '.') {69 delete push_num[push_num.length-1];70 }71 }72 73 if (calculation == true) {74 if (sign == true) {75 if (push_num [0] == '.') {76 let dot_num = push_num.join('');77 num_2 = '-0' + dot_num;78 $('#display').text(num_2); 79 } else {80 num_2 = '-' + push_num.join('');81 $('#display').text(num_2);82 } 83 } else {84 if (push_num [0] == '.') {85 let dot_num = push_num.join('');86 num_2 = '0' + dot_num;87 $('#display').text(num_2); 88 } else {89 num_2 = push_num.join('');90 $('#display').text(num_2);91 } 92 }93 } else {94 if (sign == true) {95 if (push_num [0] == '.') {96 let dot_num = push_num.join('');97 num_1 = '-0' + dot_num;98 $('#display').text(num_1);99 } else {100 num_1 = '-' + push_num.join('');101 $('#display').text(num_1); 102 }103 } else {104 if (push_num [0] == '.') {105 let dot_num = push_num.join('');106 num_1 = '0' + dot_num;107 $('#display').text(num_1);108 } else {109 num_1 = push_num.join('');110 $('#display').text(num_1); 111 }112 }113 }114 });115116 117118 $('#dot').on('click', function () {119 dot_key = true;120 });121122 $('.operator').on('click', function () {123 cal = $(this).attr('id');124 calculation = true;125 push_num = [];126 sign = false;127 key_1 = false;128 key_2 = false;129 dot_key = false;130 dot_key_1 = false;131 });132133 $('#equal').on('click', function () {134135 if (num_1 == '') {136 num_1 = 0;137 }138139 if (num_2 == '') {140 num_2 = num_1;141 }142143 let int_1 = parseFloat(num_1);144 let int_2 = parseFloat(num_2);145146 switch (cal) {147148 case 'add':149 answer = int_1 + int_2;150 break;151152 case 'subtract':153 answer = int_1 - int_2;154 break;155156 case 'multiply':157 answer = int_1 * int_2;158 break;159160 case 'divide':161 answer = int_1 / int_2;162 break;163164 default:165 answer = num_1;166 }167 $('#display').text(answer);168 num_1 = answer;169 calculation = false;170 push_num = [];171 if (num_1 < 0) {172 sign = true;173 let code_1 = parseFloat(num_1);174 let code_2 = code_1 * -1;175 push_num.push(code_2);176 } else {177 sign = false;178 push_num.push(num_1);179 }180 key_1 = false;181 key_2 = false;182 dot_key = false;183 dot_key_1 = false;184 });185186 $('.clear').on('click', function () {187 num_1 = '';188 num_2 = '';189 cal = '';190 answer = '';191 calculation = false;192 push_num = [];193 sign = false;194 key_1 = false;195 key_2 = false;196 dot_key = false;197 dot_key_1 = false;198 $('#display').text(0);199 });200201 $('#memory').on('click', function () {202 let dis_num_1 = $('#display').text();203 let dis_num_2 = parseFloat(dis_num_1);204 memo_num += dis_num_2;205 });206207 $('#memory_clear').on('click', function () {208 memo_num = 0;209 });210211 $('#memory_recall').on('click', function () {212 $('#display').text(memo_num);213 num_1 = memo_num;214 push_num = [];215 if (memo_num < 0) {216 sign = true;217 let code_3 = parseFloat(memo_num);218 let code_4 = code_3 * -1;219 push_num.push(code_4);220 } else {221 sign = false;222 push_num.push(memo_num);223 }224 key_1 = false;225 key_2 = false;226 dot_key = false;227 dot_key_1 = false;228 }); ...

Full Screen

Full Screen

factorial.js

Source:factorial.js Github

copy

Full Screen

1/*2 팩토리얼3 4 함수 factorial에는 0보다 크거나 같은 정수 num이 주어집니다. 5 이때, num의 팩토리얼을 리턴해주세요.6 팩토리얼은 그 수보다 작거나 같은 모든 양의 정수의 곱을 말합니다.7 예를 들어 3의 경우 (3 * 2 * 1) 이므로 6이 됩니다.8 제한사항 ) 9 정수 num10 (0 ≤ num ≤ 12)11 단, 0의 팩토리얼은 1입니다.12 입출력 예시 )13 input output14 ---------------15 3 616 10 362880017 18*/19// num >= 020// num <= 1221// num이 주어질 경우22// num= num * num-123// 1 = 124// 2 = 2*125// 3 = 3*2*126// 4 = 4*3*2*127// 5 = 5*4*3*2*128// 6 = 6*5*4*3*2*129// 7 = 7*6*5*4*3*2*130// 8 = 8*7*6*5*4*3*2*131// 9 = 9*8*7*6*5*4*3*2*132// 10 = 10*9*8*7*6*5*4*3*2*133// 11 = 11*10*9*8*7*6*5*4*3*2*134// 12 = 12*11*10*9*8*7*6*5*4*3*2*135// num = num36// num = num*(num-1)37// num = num*(num-1)*(num-2)38// num = num*(num-1)*(num-2)*(num-3)39// num = num*(num-1)*(num-2)*(num-3)*(num-4)40// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)41// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)42// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)*(num-7)43// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)*(num-6)*(num-8)44// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)*(num-6)*(num-8)*(num-9)45// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)*(num-6)*(num-8)*(num-9)*(num-10)46// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)*(num-6)*(num-8)*(num-9)*(num-10)*(num-11)47// num = num*(num-1)*(num-2)*(num-3)*(num-4)*(num-5)*(num-6)*(num-6)*(num-8)*(num-9)*(num-10)*(num-11)*(num-12)48// for문???49// 아직도 건들지도 못하겠네요... 얼른 공부해서 잘 풀어보겠습니다.50function factorial(num) {51 // 여기에서 작업하세요52 for (let i = 12; i > 0; i--) {53 console.log(i * (i - 1));54 }55}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var num = wpt.num;3var res = num(10);4console.log(res);5var wpt = require('wpt');6var res = wpt.num(10);7console.log(res);8var wpt = require('wpt');9var res = wpt.num(10);10console.log(res);11var wpt = require('wpt');12var res = wpt.num(10);13console.log(res);14var wpt = require('wpt');15var res = wpt.num(10);16console.log(res);17var wpt = require('wpt');18var res = wpt.num(10);19console.log(res);20var wpt = require('wpt');21var res = wpt.num(10);22console.log(res);23var wpt = require('wpt');24var res = wpt.num(10);25console.log(res);26var wpt = require('wpt');27var res = wpt.num(10);28console.log(res);29var wpt = require('wpt');30var res = wpt.num(10);31console.log(res);32var wpt = require('wpt');33var res = wpt.num(10);34console.log(res);35var wpt = require('wpt');36var res = wpt.num(10);37console.log(res);38var wpt = require('wpt');39var res = wpt.num(10);40console.log(res);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var num = wpt.num(5);3console.log(num);4module.exports = function() {5 var self = this;6 self.num = function(num) {7 return num;8 }9}10module.exports = object;11var module = require(‘module_name’);12Node.js module export and Node.js module import are

Full Screen

Using AI Code Generation

copy

Full Screen

1var num = require('wpt').num;2var result = num(5,8);3console.log(result);4module.exports = {5 num: function(a,b){6 return a+b;7 }8};9module.exports = function(a,b){10 return a+b;11};12var add = require('wpt');13add(5,8);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt-api');2wpt.num(1, 2, function(err, data) {3 console.log(data);4});5module.exports = function num(a, b, callback) {6 var result = a + b;7 callback(null, result);8};9var wpt = require('wpt-api');10wpt.num(1, 2, function(err, data) {11 console.log(data);12});13module.exports = function num(a, b, callback) {14 callback(null, a + b);15};16var wpt = require('wpt-api');17wpt.num(1, 2, function(err, data) {18 console.log(data);19});20module.exports = function(a, b, callback) {21 callback(null, a + b);22};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wptoolkit');2var num = wpt.num;3var result = num(5).add(2).multiply(3).value();4console.log(result);5var wpt = require('wptoolkit');6var num = wpt.num;7var result = num(5).add(2).multiply(3).value();8console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var num = wpt.num();3console.log(num);4var wpt = require('wpt');5var wpt1 = wpt(url1);6var wpt2 = wpt(url2);7var wpt3 = wpt(url3);8var wpt = require('wpt');9var wpt1 = wpt(url1);10var wpt2 = wpt(url2);11var wpt3 = wpt(url3);12var wpt = require('wpt');13var wpt1 = wpt(url1);14var wpt2 = wpt(url2);15var wpt3 = wpt(url3);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful