update folders
This commit is contained in:
113
snipplets/projects/JS_GameLoop/gameloop.js
Normal file
113
snipplets/projects/JS_GameLoop/gameloop.js
Normal file
@@ -0,0 +1,113 @@
|
||||
// Main variables
|
||||
let DEBUG = true;
|
||||
let canvas;
|
||||
let context;
|
||||
let cW;
|
||||
let cH;
|
||||
|
||||
// FPS
|
||||
let secondsPassed;
|
||||
let oldTimeStamp;
|
||||
let fps;
|
||||
|
||||
let dragging = false;
|
||||
|
||||
function mMove(e) {
|
||||
'use strict';
|
||||
|
||||
if (dragging) {
|
||||
point.pX = e.offsetX * cW / canvas.clientWidth | 0;
|
||||
point.pY = e.offsetY * cH / canvas.clientHeight | 0;
|
||||
};
|
||||
}
|
||||
|
||||
function mDown(e) {
|
||||
'use strict';
|
||||
|
||||
dragging = true;
|
||||
}
|
||||
|
||||
function mUp(e) {
|
||||
'use strict';
|
||||
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
function clearContext() {
|
||||
'use strict';
|
||||
|
||||
context.fillStyle = '#b27e56';
|
||||
context.fillRect(0, 0, cW, cH);
|
||||
}
|
||||
|
||||
// Init
|
||||
window.onload = function() {
|
||||
'use strict';
|
||||
|
||||
canvas = document.getElementById('game');
|
||||
context = canvas.getContext('2d');
|
||||
cW = canvas.width;
|
||||
cH = canvas.height;
|
||||
|
||||
canvas.style.height = window.innerHeight + "px";
|
||||
if (DEBUG) {
|
||||
console.log('Canvas set size to ' + window.innerHeight + 'px');
|
||||
console.log(canvas.getBoundingClientRect());
|
||||
};
|
||||
|
||||
canvas.addEventListener('mousedown', mDown, false);
|
||||
canvas.addEventListener('mouseup', mUp, false);
|
||||
canvas.addEventListener('mousemove', mMove, false);
|
||||
|
||||
canvas.addEventListener('touchstart', mDown, false);
|
||||
canvas.addEventListener('touchend', mUp, false);
|
||||
canvas.addEventListener('touchmove', mMove, false);
|
||||
|
||||
window.requestAnimationFrame(gameLoop);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', function() {
|
||||
'use strict';
|
||||
|
||||
let canvas = document.getElementById('game');
|
||||
canvas.style.height = window.innerHeight + "px";
|
||||
|
||||
if (DEBUG) {
|
||||
console.log('Canvas resized to ' + window.innerHeight + 'px');
|
||||
console.log(canvas.getBoundingClientRect());
|
||||
};
|
||||
}, true);
|
||||
|
||||
// GameLoop
|
||||
function gameLoop(timeStamp) {
|
||||
'use strict';
|
||||
|
||||
// fps counter
|
||||
secondsPassed = (timeStamp - oldTimeStamp) / 1000;
|
||||
oldTimeStamp = timeStamp;
|
||||
fps = Math.round(1 / secondsPassed);
|
||||
// end fps counter
|
||||
|
||||
update();
|
||||
draw();
|
||||
|
||||
if (DEBUG) {
|
||||
context.font = '15px Arial';
|
||||
context.fillStyle = '#101024';
|
||||
context.fillText('FPS: ' + fps, 10, 20);
|
||||
};
|
||||
|
||||
window.requestAnimationFrame(gameLoop);
|
||||
}
|
||||
|
||||
function update() {
|
||||
'use strict';
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
function draw() {
|
||||
'use strict';
|
||||
|
||||
clearContext();
|
||||
}
|
||||
7
snipplets/projects/Kemal.cr/example.cr
Normal file
7
snipplets/projects/Kemal.cr/example.cr
Normal file
@@ -0,0 +1,7 @@
|
||||
require "kemal"
|
||||
|
||||
get "/" do
|
||||
"Hello World!"
|
||||
end
|
||||
|
||||
Kemal.run
|
||||
19
snipplets/projects/Kemal.cr/routes.cr
Normal file
19
snipplets/projects/Kemal.cr/routes.cr
Normal file
@@ -0,0 +1,19 @@
|
||||
get "/" do
|
||||
..show something..
|
||||
end
|
||||
|
||||
post "/" do
|
||||
..create something..
|
||||
end
|
||||
|
||||
put "/" do
|
||||
..replace something..
|
||||
end
|
||||
|
||||
patch "/" do
|
||||
..modify something..
|
||||
end
|
||||
|
||||
delete "/" do
|
||||
..a
|
||||
end
|
||||
3
snipplets/projects/Kemal.cr/shards.yml
Normal file
3
snipplets/projects/Kemal.cr/shards.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
kemal:
|
||||
github: kemalcr/kemal
|
||||
43
snipplets/projects/Pixi.js/app.js
Normal file
43
snipplets/projects/Pixi.js/app.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const DEBUG = true;
|
||||
|
||||
let app;
|
||||
|
||||
/** PIXI and PIXI.Assets init */
|
||||
window.onload = function() {
|
||||
'use strict';
|
||||
|
||||
app = new PIXI.Application({
|
||||
width: 640,
|
||||
height: 360,
|
||||
backgroundColor: 0x2a2a3a,
|
||||
});
|
||||
document.body.appendChild(app.view);
|
||||
|
||||
// PIXI.Assets.add('texture_name', '/assets/texture.png');
|
||||
|
||||
// let promise = PIXI.Assets.load(
|
||||
// ['texture_name'],
|
||||
// (progress) => {
|
||||
// if (DEBUG)
|
||||
// console.log(`Assets loading progress: ${progress * 100}%`);
|
||||
// });
|
||||
|
||||
// promise.then((value) => {
|
||||
// backgroundTextures = value;
|
||||
// initLevel();
|
||||
// });
|
||||
}
|
||||
|
||||
/** Level init */
|
||||
function initLevel() {
|
||||
'use strict';
|
||||
|
||||
app.ticker.add(gameLoop);
|
||||
}
|
||||
|
||||
/** Game loop */
|
||||
function gameLoop(delta) {
|
||||
'use strict';
|
||||
|
||||
//
|
||||
}
|
||||
15
snipplets/projects/Pixi.js/index.html
Normal file
15
snipplets/projects/Pixi.js/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>pixi.js - template</title>
|
||||
<script type="text/javascript" src="pixi.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- -->
|
||||
</div>
|
||||
<script type="text/javascript" src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
10
snipplets/projects/Solar2D/SampleProject/HISTORY.md
Normal file
10
snipplets/projects/Solar2D/SampleProject/HISTORY.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## Legend
|
||||
- 🐛 - Bug
|
||||
- ✔️ - Fixed
|
||||
- ❌ - Removed
|
||||
- ➕ - Added
|
||||
- ℹ️ - Information
|
||||
- ♻️ - Edited
|
||||
|
||||
## 0.1.0 - [17/04/2021] - (not work)
|
||||
-
|
||||
1
snipplets/projects/Solar2D/SampleProject/TODO.md
Normal file
1
snipplets/projects/Solar2D/SampleProject/TODO.md
Normal file
@@ -0,0 +1 @@
|
||||
-
|
||||
37
snipplets/projects/Solar2D/SampleProject/build.settings
Normal file
37
snipplets/projects/Solar2D/SampleProject/build.settings
Normal file
@@ -0,0 +1,37 @@
|
||||
settings =
|
||||
{
|
||||
orientation =
|
||||
{
|
||||
default = "portrait",
|
||||
supported = { "portrait", },
|
||||
},
|
||||
|
||||
android =
|
||||
{
|
||||
usesPermissions =
|
||||
{
|
||||
"android.permission.INTERNET",
|
||||
},
|
||||
},
|
||||
|
||||
iphone =
|
||||
{
|
||||
xcassets = "Images.xcassets",
|
||||
plist =
|
||||
{
|
||||
UIStatusBarHidden = false,
|
||||
UILaunchStoryboardName = "LaunchScreen",
|
||||
},
|
||||
},
|
||||
|
||||
plugins =
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
excludeFiles =
|
||||
{
|
||||
all = { "Icon.png", "Icon-*dpi.png", "Images.xcassets", },
|
||||
android = { "LaunchScreen.storyboardc", },
|
||||
},
|
||||
}
|
||||
18
snipplets/projects/Solar2D/SampleProject/config.lua
Normal file
18
snipplets/projects/Solar2D/SampleProject/config.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
application =
|
||||
{
|
||||
content =
|
||||
{
|
||||
width = 1080,
|
||||
height = 1920,
|
||||
scale = "letterbox",
|
||||
fps = 60,
|
||||
|
||||
--[[
|
||||
imageSuffix =
|
||||
{
|
||||
["@2x"] = 2,
|
||||
["@4x"] = 4,
|
||||
},
|
||||
--]]
|
||||
},
|
||||
}
|
||||
0
snipplets/projects/Solar2D/SampleProject/main.lua
Normal file
0
snipplets/projects/Solar2D/SampleProject/main.lua
Normal file
70
snipplets/projects/Solar2D/SampleProject/scenes/game.lua
Normal file
70
snipplets/projects/Solar2D/SampleProject/scenes/game.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
local composer = require('composer')
|
||||
|
||||
local scene = composer.newScene()
|
||||
|
||||
local groupBack
|
||||
local groupMain
|
||||
local groupUI
|
||||
|
||||
|
||||
function gameLoop()
|
||||
--
|
||||
end
|
||||
|
||||
local function onFrame(event)
|
||||
--
|
||||
end
|
||||
|
||||
|
||||
function scene:create(event)
|
||||
local sceneGroup = self.view
|
||||
|
||||
groupBack = display.newGroup()
|
||||
groupMain = display.newGroup()
|
||||
groupUI = display.newGroup()
|
||||
|
||||
local debugRect = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight )
|
||||
debugRect:setFillColor(0.807, 0.925, 0.956)
|
||||
end
|
||||
|
||||
|
||||
function scene:show(event)
|
||||
local sceneGroup = self.view
|
||||
local phase = event.phase
|
||||
|
||||
if (phase == "will") then
|
||||
-- Code here runs when the scene is still off screen (but is about to come on screen)
|
||||
|
||||
elseif (phase == "did") then
|
||||
gameLoopTimer = timer.performWithDelay(500, gameLoop, 0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function scene:hide(event)
|
||||
local sceneGroup = self.view
|
||||
local phase = event.phase
|
||||
|
||||
if (phase == "will") then
|
||||
-- Code here runs when the scene is on screen (but is about to go off screen)
|
||||
|
||||
elseif (phase == "did") then
|
||||
-- Code here runs immediately after the scene goes entirely off screen
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function scene:destroy(event)
|
||||
local sceneGroup = self.view
|
||||
-- Code here runs prior to the removal of scene's view
|
||||
end
|
||||
|
||||
|
||||
scene:addEventListener('create', scene)
|
||||
scene:addEventListener('show', scene)
|
||||
scene:addEventListener('hide', scene)
|
||||
scene:addEventListener('destroy', scene)
|
||||
Runtime:addEventListener('enterFrame', onFrame)
|
||||
|
||||
return scene
|
||||
Reference in New Issue
Block a user