Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 395dae5

Browse files
Merge pull request avinashkranjan#2714 from Durgesh4993/master
Gunship13k
2 parents d0ea777 + fdcc5e8 commit 395dae5

File tree

21 files changed

+2413
-10
lines changed

21 files changed

+2413
-10
lines changed

‎GUI-Stopwatch/readme.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
# GUI CALCULATOR
1+
# Gunship13k
22

3-
This script user Tkinter to provide a Graphical User Interface.
3+
## Gameplay
44

5-
No Requirements because Tkinter and time is inbuilt
5+
Shoot enemies to score points.
66

7-
These are customizable
7+
Chain kills to increase your multiplier and power up your cannon.
88

9-
1. The refresh rate (how fast the display updates)
10-
2. Colours: background,button colour
11-
3. Text: font, size, colour
12-
4. The size of the GUI window can be adjusted during execution
13-
5. The default size of the GUI window can be adjusted in the script
14-
6. The button text, position, size
9+
If an enemy gets past you, the score multiplier is reset!
10+
11+
Hitting an enemy with your ship will trigger an explosion and kill all everything.
12+
13+
But if you get hit three times it's Game Over!
14+
15+
## Controls
16+
17+
Move left and right using [a] and [d] or arrow left and right.
18+
19+
Aim cannons with mouse cursor.
20+
21+
Fire with [space] or left mouse button.
22+
23+
Pause and resume with [p].

‎Gunship/app/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Gunship13k
2+
3+
## Gameplay
4+
5+
Shoot enemies to score points.
6+
7+
Chain kills to increase your multiplier and power up your cannon.
8+
9+
If an enemy gets past you, the score multiplier is reset!
10+
11+
Hitting an enemy with your ship will trigger an explosion and kill all everything.
12+
13+
But if you get hit three times it's Game Over!
14+
15+
## Controls
16+
17+
Move left and right using [a] and [d] or arrow left and right.
18+
19+
Aim cannons with mouse cursor.
20+
21+
Fire with [space] or left mouse button.
22+
23+
Pause and resume with [p].

‎Gunship/app/assets/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html class="no-js" lang="">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>Gunship13k</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
<link rel="stylesheet" href="js13k.css">
10+
</head>
11+
<body>
12+
<canvas id="canvas" width="500" height="550"></canvas>
13+
<div style="display: none;">
14+
<canvas id="shipsprite" width="42" height="127"></canvas>
15+
<canvas id="smokesprite" width="200" height="200"></canvas>
16+
</div>
17+
<script src="js13k.js"></script>
18+
</body>
19+
</html>

‎Gunship/app/helpers/draw.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
(function(){
2+
// Helper method to draw a shape from an array of points
3+
window.drawShape = function(ctx, points, tx, mirror, stroke, fill){
4+
ctx.beginPath();
5+
ctx.moveTo(tx.x+points[0][0], tx.y+points[0][1]);
6+
7+
// Draw the path
8+
var numPoints = points.length;
9+
var i;
10+
for(i=1; i<numPoints; ++i){
11+
ctx.lineTo(tx.x+points[i][0], tx.y+points[i][1]);
12+
}
13+
14+
// If mirror is true then run through the points again and draw a
15+
// mirrored version
16+
if(mirror == true){
17+
for(i=numPoints-1; i>-1; --i){
18+
ctx.lineTo(tx.x+(-points[i][0]), tx.y+points[i][1]);
19+
}
20+
}
21+
22+
// Apply line styles
23+
if(fill == true) ctx.fill();
24+
if(stroke == true) ctx.stroke();
25+
}
26+
27+
// Helper function for drawing circles
28+
window.drawCircle = function(ctx, x, y, r, stroke, fill){
29+
ctx.beginPath();
30+
ctx.arc(x, y, r, 0, 2*Math.PI);
31+
32+
if(fill == true) ctx.fill();
33+
if(stroke !== false) ctx.stroke();
34+
}
35+
36+
window.drawGradientCircle = function(ctx, x, y, r, color, opacity){
37+
ctx.beginPath();
38+
var gradient = ctx.createRadialGradient(x, y, 5, x, y, r);
39+
gradient.addColorStop(0, 'rgba('+color+', '+opacity+')');
40+
gradient.addColorStop(0.5, 'rgba('+color+', '+opacity+')');
41+
gradient.addColorStop(1, 'rgba('+color+', 0)');
42+
ctx.fillStyle = gradient;
43+
44+
ctx.arc(x, y, r, 0, 2*Math.PI);
45+
ctx.fill();
46+
}
47+
48+
// Helper function for drawing arcs
49+
window.drawArc = function(ctx, x, y, rotation, start, end){
50+
ctx.beginPath();
51+
ctx.arc(x, y, rotation, start, end);
52+
ctx.stroke();
53+
}
54+
55+
// Helper function to draw a grid in a bounding box
56+
window.drawGrid = function(ctx, options){
57+
var bounds = options.bounds;
58+
var step = options.step;
59+
var offset = options.offset;
60+
var verticalSteps = Math.floor(bounds.bottom / step);
61+
62+
ctx.lineWidth = 1;
63+
ctx.strokeStyle = 'rgba(80, 80, 80, 1)';
64+
ctx.beginPath();
65+
66+
var y;
67+
for(var i=0; i<verticalSteps; ++i){
68+
y = i*step + offset;
69+
ctx.moveTo(bounds.left, y);
70+
ctx.lineTo(bounds.right, y);
71+
}
72+
ctx.stroke();
73+
}
74+
75+
// Draw a line of text
76+
window.drawTextLine = function(ctx, text, x, y){
77+
ctx.fillStyle = 'rgba(255, 255, 255, 1)';
78+
ctx.fillText(text, x, y);
79+
}
80+
81+
// Draw a paragraph of text
82+
window.drawParagraph = function(ctx, para, x, y, textAlign){
83+
if(textAlign == undefined) textAlign = 'left';
84+
var headingX = x;
85+
switch(textAlign){
86+
case 'left' :
87+
x -= 200;
88+
headingX = x - 20;
89+
break;
90+
}
91+
92+
ctx.textAlign = textAlign
93+
ctx.font = '18px Arial';
94+
drawTextLine(ctx, para[0], headingX, y);
95+
96+
y += 10;
97+
ctx.font = '14px Arial';
98+
for(var i=1; i<para.length; ++i){
99+
drawTextLine(ctx, para[i], x, y+(20*i));
100+
}
101+
}
102+
})();

‎Gunship/app/helpers/effects.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// (function(){
2+
// Effects = function(){
3+
// this.sounds = {};
4+
// }
5+
// Effects.prototype.add = function(key, count, settings){
6+
// this.sounds[key] = [];
7+
// settings.forEach(function(el, index){
8+
// this.sounds[key].push({
9+
// tick: 0,
10+
// count: count,
11+
// pool: []
12+
// });
13+
// for(var i=0; i<count; ++i){
14+
// var audio = new Audio();
15+
// audio.src = jsfxr(el);
16+
// this.sounds[key][index].pool.push(audio);
17+
// }
18+
// }, this);
19+
// };
20+
// Effects.prototype.play = function(key){
21+
// var sound = this.sounds[key];
22+
// var soundData = sound.length > 1 ? sound[Math.floor(Math.random()*sound.length)] : sound[0];
23+
// soundData.pool[soundData.tick].play();
24+
// soundData.tick < soundData.count-1 ? soundData.tick++ : soundData.tick = 0;
25+
// };
26+
// window.Effects = new Effects();
27+
// })();

‎Gunship/app/helpers/frame_timer.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
(function(){
2+
window.FrameTimer = function(options){
3+
var self = this;
4+
5+
self._frames = [];
6+
self._graph = [];
7+
self._fps = 0;
8+
self.bounds = options.bounds;
9+
10+
// History array of delta values passed into update()
11+
self._deltaHistory = [];
12+
13+
// History array ms between calls to draw()
14+
self._drawHistory = [];
15+
self._lastDraw = 0;
16+
17+
// Calculates FPS by sampling previous frames. Keep trask of the last 30
18+
// frameTime values, when we have 30 we take the average and use it to
19+
// calculate the frame rate.
20+
self.update = function(frameTime, delta){
21+
self._deltaHistory.push(delta);
22+
if(self._deltaHistory.length > self.bounds.right) self._deltaHistory.shift();
23+
}
24+
25+
self.draw = function(ctx){
26+
27+
// Work out and store how long it's been since the last draw
28+
var now = performance.now();
29+
var ms = now - self._lastDraw;
30+
self._drawHistory.push(ms);
31+
if(self._drawHistory.length > self.bounds.right) self._drawHistory.shift();
32+
self._lastDraw = now;
33+
34+
// Draw the two graphs the full width of the bounds
35+
self.drawGraph(ctx, self._drawHistory, 'rgba(255, 0, 0, 0.5)');
36+
self.drawGraph(ctx, self._deltaHistory, 'rgba(0, 255, 0, 0.5)');
37+
}
38+
39+
self.drawGraph = function(ctx, graph, color){
40+
var points = [];
41+
for(var i=0; i<graph.length; ++i){
42+
points.push([i, 50-graph[i]]);
43+
}
44+
ctx.strokeStyle = color;
45+
if(points.length){
46+
drawShape(ctx, points, {x: self.bounds.right-graph.length, y: 0}, false, true);
47+
}
48+
}
49+
}
50+
})();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /