| 103 | } |
| 104 | |
| 105 | function update(){ |
| 106 | bullet.x += bullet.vx; |
| 107 | wind.x -= wind.vx; |
| 108 | player.y -= player.vy; |
| 109 | |
| 110 | if (player.y <= h/2-(18/100*h)){ |
| 111 | player.y = h/2-(18/100*h); |
| 112 | } |
| 113 | |
| 114 | if (player.y >= h/2+(6.5/100*h)){ |
| 115 | player.y = h/2+(6.5/100*h); |
| 116 | } |
| 117 | |
| 118 | if (bullet.x >= w){ |
| 119 | bullet.x = player.x+5; |
| 120 | bullet.vx = 0; |
| 121 | } |
| 122 | |
| 123 | if ( |
| 124 | bullet.x <= (balloon.x + balloon.width) |
| 125 | && balloon.x <= (bullet.x + bullet.width) |
| 126 | && bullet.y <= (balloon.y + balloon.height) |
| 127 | && balloon.y <= (bullet.y + bullet.height) |
| 128 | ){ |
| 129 | balloon.y = Math.floor(Math.random()*((4*h)-h)+h); |
| 130 | balloon.x = Math.floor(Math.random()*((w/2+20/100*w)-(w/2-(20/100*w)))+(w/2-(20/100))); |
| 131 | bullet.x = player.x+5; |
| 132 | bullet.vx = 0; |
| 133 | score += 1; |
| 134 | } |
| 135 | |
| 136 | if ( |
| 137 | bullet.x <= (balloon2.x + balloon2.width) |
| 138 | && balloon2.x <= (bullet.x + bullet.width) |
| 139 | && bullet.y <= (balloon2.y + balloon2.height) |
| 140 | && balloon2.y <= (bullet.y + bullet.height) |
| 141 | ){ |
| 142 | balloon2.y = Math.floor(Math.random()*((3*h)-h)+h); |
| 143 | balloon2.x = Math.floor(Math.random()*((w/2+20/100*w)-(w/2-(20/100*w)))+(w/2-(20/100))); |
| 144 | bullet.x = player.x+5; |
| 145 | bullet.vx = 0; |
| 146 | score += 1; |
| 147 | } |
| 148 | if ( |
| 149 | bullet.x <= (balloon3.x + balloon3.width) |
| 150 | && balloon3.x <= (bullet.x + bullet.width) |
| 151 | && bullet.y <= (balloon3.y + balloon3.height) |
| 152 | && balloon3.y <= (bullet.y + bullet.height) |
| 153 | ){ |
| 154 | balloon3.y = Math.floor(Math.random()*((2*h)-h)+h); |
| 155 | balloon3.x = Math.floor(Math.random()*((w/2+20/100*w)-(w/2-(20/100*w)))+(w/2-(20/100))); |
| 156 | bullet.x = player.x+5; |
| 157 | bullet.vx = 0; |
| 158 | score += 1; |
| 159 | } |
| 160 | |
| 161 | if (wind.x < -100){ |
| 162 | wind.x = Math.floor(Math.random()*((5*w)-w)+w); |