Initial commit
31
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [{
|
||||||
|
"preLaunchTask": "Build",
|
||||||
|
"name": "(gdb) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/a.out",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
64
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"map1": "plaintext",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"codecvt": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"strstream": "cpp"
|
||||||
|
}
|
||||||
|
}
|
18
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build",
|
||||||
|
"command": "g++ *.cpp -std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple -o a.out",
|
||||||
|
"type": "shell",
|
||||||
|
"args": [],
|
||||||
|
"problemMatcher": [
|
||||||
|
"$tsc"
|
||||||
|
],
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always"
|
||||||
|
},
|
||||||
|
"group": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
8
Block.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "Block.h"
|
||||||
|
|
||||||
|
Block::Block(int x, int y, int R, int B, int G)
|
||||||
|
{
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
color = std::make_tuple(R, G, B);
|
||||||
|
}
|
14
Block.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
class Block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Block(){};
|
||||||
|
Block(int x, int y, int R, int B, int G);
|
||||||
|
void display(float CameraX, float CameraY, float Zoom);
|
||||||
|
private:
|
||||||
|
int X;
|
||||||
|
int Y;
|
||||||
|
std::tuple<int, int, int> color;
|
||||||
|
};
|
7
C++/scripts/build.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#Compiles the entire program then runs it, producing an executable.
|
||||||
|
#C++
|
||||||
|
printf "Running program...\n\n\n"
|
||||||
|
if g++ $(find . -type f -name "*.cpp") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then
|
||||||
|
./${PROJECT_NAME} "$@"
|
||||||
|
fi
|
||||||
|
printf "\n\n"
|
20
C++/scripts/commit.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#Adds a commit message and pushes project to github repository.
|
||||||
|
#C++
|
||||||
|
COMMIT_MESSAGE="$*"
|
||||||
|
FIRST_LINE=true
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
if [ "$FIRST_LINE" = true ]; then
|
||||||
|
COMMIT_MESSAGE+="
|
||||||
|
|
||||||
|
Co-authored-by: $line"
|
||||||
|
FIRST_LINE=false
|
||||||
|
else
|
||||||
|
COMMIT_MESSAGE+="
|
||||||
|
Co-authored-by: $line"
|
||||||
|
fi
|
||||||
|
done < utils/.coauthors
|
||||||
|
git add -u
|
||||||
|
git add *
|
||||||
|
git commit -m "$COMMIT_MESSAGE"
|
||||||
|
git push
|
6
C++/scripts/filelist
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
build.sh
|
||||||
|
commit.sh
|
||||||
|
lines.sh
|
||||||
|
release.sh
|
||||||
|
temp
|
||||||
|
web.sh
|
14
C++/scripts/lines.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#Returns the line counts of your project.
|
||||||
|
#C++
|
||||||
|
shopt -s extglob
|
||||||
|
ls -1 @(*.h|*.cpp) > temp
|
||||||
|
while read a; do
|
||||||
|
if [ "$a" != "pixelGameEngine.h" ] && [ "$a" != "soundwaveEngine.h" ] && [ "$a" != "splash.h" ];
|
||||||
|
then
|
||||||
|
echo -e "$a\n" >> temp2
|
||||||
|
fi
|
||||||
|
done < temp
|
||||||
|
wc -l $(cat temp2)
|
||||||
|
|
||||||
|
rm temp
|
||||||
|
rm temp2
|
6
C++/scripts/md5
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
build.sh:530634457ea9041267c05d4ced95eee1 -
|
||||||
|
commit.sh:d03a46e721060c22ccb146e19d27e70a -
|
||||||
|
lines.sh:3b907786f7fc9204025993016c9080de -
|
||||||
|
release.sh:a54e2002be80814cc1293a11dff4d116 -
|
||||||
|
temp:d41d8cd98f00b204e9800998ecf8427e -
|
||||||
|
web.sh:3dcc2fe7e036359eedd257a864e9a1e1 -
|
7
C++/scripts/release.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#Creates a release build that focuses on high runtime performance.
|
||||||
|
#C++
|
||||||
|
printf "Running program...\n\n\n"
|
||||||
|
if g++ $(find . -type f -name "*.cpp") ${CUSTOM_PARAMS} -O3 -s -DNDEBUG -o ${PROJECT_NAME}; then
|
||||||
|
./${PROJECT_NAME} "$@"
|
||||||
|
fi
|
||||||
|
printf "\n\n"
|
0
C++/scripts/temp
Normal file
18
C++/scripts/web.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#Compiles emscripten instance of this project for the web.
|
||||||
|
#C++
|
||||||
|
if [ -d "assets" ]; then
|
||||||
|
em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h --preload-file ./assets
|
||||||
|
else
|
||||||
|
em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp buildtemplate.html ${PROJECT_NAME}.html
|
||||||
|
sed -i "s/_REPLACEME_/$PROJECT_NAME.js/" ${PROJECT_NAME}.html
|
||||||
|
|
||||||
|
if [ "$1" == "headless" ]; then
|
||||||
|
echo "Running as headless web server"
|
||||||
|
emrun --no_browser ${PROJECT_NAME}.html
|
||||||
|
else
|
||||||
|
emrun --serve_after_close ${PROJECT_NAME}.html
|
||||||
|
fi
|
||||||
|
|
BIN
C++ProjectTemplate
Executable file
75
C++ProjectTemplate.html
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Emscripten-Generated Code</title>
|
||||||
|
<style>
|
||||||
|
html,body { width: 100%; height: 100%; }
|
||||||
|
body { font-family: arial; margin: 0; padding: 0; background: #000; }
|
||||||
|
|
||||||
|
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||||
|
div.emscripten_border { border: none; }
|
||||||
|
|
||||||
|
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
||||||
|
canvas.emscripten { border: 0px none; background-color: black; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var Module = {
|
||||||
|
preRun: [],
|
||||||
|
postRun: [],
|
||||||
|
canvas: (function() {
|
||||||
|
var canvas = document.getElementById('canvas');
|
||||||
|
|
||||||
|
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||||
|
// application robust, you may want to override this behavior before shipping!
|
||||||
|
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||||
|
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script async type="text/javascript" src="C++ProjectTemplate.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
Module.canvas.addEventListener("resize", (e) => {
|
||||||
|
|
||||||
|
var viewWidth = e.detail.width;
|
||||||
|
var viewHeight = e.detail.width / Module._olc_WindowAspectRatio;
|
||||||
|
|
||||||
|
if(viewHeight > e.detail.height)
|
||||||
|
{
|
||||||
|
viewHeight = e.detail.height;
|
||||||
|
viewWidth = e.detail.height * Module._olc_WindowAspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update dom attributes
|
||||||
|
Module.canvas.setAttribute("width", viewWidth);
|
||||||
|
Module.canvas.setAttribute("height", viewHeight);
|
||||||
|
|
||||||
|
var top = (e.detail.height - viewHeight) / 2;
|
||||||
|
var left = (e.detail.width - viewWidth) / 2;
|
||||||
|
|
||||||
|
// update styles
|
||||||
|
Module.canvas.style.position = "fixed";
|
||||||
|
Module.canvas.style.top = top.toString() + "px";
|
||||||
|
Module.canvas.style.left = left.toString() + "px";
|
||||||
|
Module.canvas.style.width = "";
|
||||||
|
Module.canvas.style.height = "";
|
||||||
|
|
||||||
|
// trigger PGE update
|
||||||
|
Module._olc_PGE_UpdateWindowSize(viewWidth, viewHeight);
|
||||||
|
|
||||||
|
// ensure canvas has focus
|
||||||
|
Module.canvas.focus();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
1
C++ProjectTemplate.js
Normal file
BIN
C++ProjectTemplate.wasm
Executable file
6
Map.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "Map.h"
|
||||||
|
|
||||||
|
void Map::test(){
|
||||||
|
printf("Hello Map\n");
|
||||||
|
}
|
||||||
|
|
10
Map.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class Player;
|
||||||
|
|
||||||
|
class Map{
|
||||||
|
public:
|
||||||
|
Player*p;
|
||||||
|
void test();
|
||||||
|
};
|
6
Player.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
void Player::test(){
|
||||||
|
printf("Hello Player\n");
|
||||||
|
}
|
||||||
|
|
10
Player.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
|
class Player{
|
||||||
|
public:
|
||||||
|
Map*map;
|
||||||
|
void test();
|
||||||
|
};
|
33
README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
This repository contains general build scripts and pipelines for all languages that I incorporate in my projects. The goal is to provide an easy retrieval and update system for the project. Each script will be a shell script containing the following template:
|
||||||
|
```bash
|
||||||
|
#Short description about what I do
|
||||||
|
#Language[Folder]
|
||||||
|
# #The script's code goes in here.
|
||||||
|
# rm -Rf out/*
|
||||||
|
# javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java
|
||||||
|
# printf "\n\n\nRunning Program...\n\n"
|
||||||
|
# cd $OUT_DIR
|
||||||
|
# java ${MAIN_CLASS} "$@"
|
||||||
|
# ../scripts/clean.sh
|
||||||
|
|
||||||
|
```
|
||||||
|
Each language will be in the following structure:
|
||||||
|
```
|
||||||
|
-<Language>
|
||||||
|
--<scripts>
|
||||||
|
---[script files.sh]
|
||||||
|
```
|
||||||
|
|
||||||
|
The `sig` script will display by default any scripts in the `scripts` folder, therefore when creating a project, copy over the scripts folder of the desired language into your project then the `sig` script handles the rest appropriately. If your project requires multiple languages and build setups, then you can use the `sig2` command, which has an additional parameter to specify the language when running it. When setting up a multi-language setup, you'll just copy the entire folder to include the programming language itself. So a multi-language project structure may look something like this:
|
||||||
|
```
|
||||||
|
-C
|
||||||
|
--scripts
|
||||||
|
---build.sh
|
||||||
|
---clean.sh
|
||||||
|
---make.sh
|
||||||
|
-Java
|
||||||
|
--scripts
|
||||||
|
---build.sh
|
||||||
|
---clean.sh
|
||||||
|
---jar.sh
|
||||||
|
```
|
BIN
art/black.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/blue.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/car.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/cars.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
art/grass.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
art/green.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/hills.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
art/old/car 2.png
Normal file
After Width: | Height: | Size: 662 B |
BIN
art/old/car0.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
art/old/car1.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
art/old/car2.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
art/old/checker0.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
art/old/curb.png
Normal file
After Width: | Height: | Size: 363 B |
BIN
art/old/curb0.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
art/old/grass/grass0.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
art/old/grass/grass1.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
art/old/grass/grass2.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
art/old/grass/grass3.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
art/old/grass/grass4.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
art/old/grass/grass5.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
art/old/road0.png
Normal file
After Width: | Height: | Size: 892 B |
BIN
art/old/road1.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
art/old/title/title 0.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
art/old/title/title 1.png
Normal file
After Width: | Height: | Size: 477 KiB |
BIN
art/old/title/title 2.png
Normal file
After Width: | Height: | Size: 495 KiB |
BIN
art/old/title/title 2b.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
art/old/title/title 3.png
Normal file
After Width: | Height: | Size: 569 KiB |
BIN
art/old/title/title 3a.png
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
art/old/title/title 3b.png
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
art/old/title/title 4.png
Normal file
After Width: | Height: | Size: 334 KiB |
BIN
art/old/title/title 40%.png
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
art/old/title/title 4b.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
art/old/title/title 5.png
Normal file
After Width: | Height: | Size: 333 KiB |
BIN
art/old/title/title 50%.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
art/old/title/title 5b.png
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
art/old/title/title 6.png
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
art/old/title/title 7.png
Normal file
After Width: | Height: | Size: 441 KiB |
BIN
art/old/title/title 7b.png
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
art/orange.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/purple.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/red.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
art/road.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
art/start.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
art/title.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
art/title.psd
Normal file
BIN
art/white.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
75
buildtemplate.html
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Emscripten-Generated Code</title>
|
||||||
|
<style>
|
||||||
|
html,body { width: 100%; height: 100%; }
|
||||||
|
body { font-family: arial; margin: 0; padding: 0; background: #000; }
|
||||||
|
|
||||||
|
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||||
|
div.emscripten_border { border: none; }
|
||||||
|
|
||||||
|
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
||||||
|
canvas.emscripten { border: 0px none; background-color: black; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var Module = {
|
||||||
|
preRun: [],
|
||||||
|
postRun: [],
|
||||||
|
canvas: (function() {
|
||||||
|
var canvas = document.getElementById('canvas');
|
||||||
|
|
||||||
|
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||||
|
// application robust, you may want to override this behavior before shipping!
|
||||||
|
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||||
|
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script async type="text/javascript" src="_REPLACEME_"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
Module.canvas.addEventListener("resize", (e) => {
|
||||||
|
|
||||||
|
var viewWidth = e.detail.width;
|
||||||
|
var viewHeight = e.detail.width / Module._olc_WindowAspectRatio;
|
||||||
|
|
||||||
|
if(viewHeight > e.detail.height)
|
||||||
|
{
|
||||||
|
viewHeight = e.detail.height;
|
||||||
|
viewWidth = e.detail.height * Module._olc_WindowAspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update dom attributes
|
||||||
|
Module.canvas.setAttribute("width", viewWidth);
|
||||||
|
Module.canvas.setAttribute("height", viewHeight);
|
||||||
|
|
||||||
|
var top = (e.detail.height - viewHeight) / 2;
|
||||||
|
var left = (e.detail.width - viewWidth) / 2;
|
||||||
|
|
||||||
|
// update styles
|
||||||
|
Module.canvas.style.position = "fixed";
|
||||||
|
Module.canvas.style.top = top.toString() + "px";
|
||||||
|
Module.canvas.style.left = left.toString() + "px";
|
||||||
|
Module.canvas.style.width = "";
|
||||||
|
Module.canvas.style.height = "";
|
||||||
|
|
||||||
|
// trigger PGE update
|
||||||
|
Module._olc_PGE_UpdateWindowSize(viewWidth, viewHeight);
|
||||||
|
|
||||||
|
// ensure canvas has focus
|
||||||
|
Module.canvas.focus();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
dependentClasses.zip
Normal file
14
diff
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
1114d1113
|
||||||
|
< void SetFPSDisplay(bool display);
|
||||||
|
1176,1177c1175
|
||||||
|
< int nFrameCount = 0;
|
||||||
|
< bool showFPS = true;
|
||||||
|
---
|
||||||
|
> int nFrameCount = 0;
|
||||||
|
3203,3204d3200
|
||||||
|
< void PixelGameEngine::SetFPSDisplay(bool display)
|
||||||
|
< { showFPS=display; }
|
||||||
|
3543c3539
|
||||||
|
< std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + ((showFPS)?" - FPS: " + std::to_string(nFrameCount):"");
|
||||||
|
---
|
||||||
|
> std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + " - FPS: " + std::to_string(nFrameCount);
|
BIN
dirtblock.png
Normal file
After Width: | Height: | Size: 35 KiB |
70
main.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#define OLC_PGE_APPLICATION
|
||||||
|
#include "pixelGameEngine.h"
|
||||||
|
|
||||||
|
using namespace olc;
|
||||||
|
|
||||||
|
class Circles : public olc::PixelGameEngine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Circles()
|
||||||
|
{
|
||||||
|
sAppName = "Circles";
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
int CIRCLE_PRECISION=32;
|
||||||
|
|
||||||
|
void DrawCircleDecal(vf2d pos,float radius,Pixel col=WHITE) {
|
||||||
|
std::vector<vf2d> poly;
|
||||||
|
std::vector<vf2d> uvs;
|
||||||
|
for (int i=0;i<CIRCLE_PRECISION;i++) {
|
||||||
|
poly.push_back({pos.x+sinf(2*M_PI/CIRCLE_PRECISION*i)*radius,pos.y+cosf(2*M_PI/CIRCLE_PRECISION*i)*radius});
|
||||||
|
uvs.push_back({0,0});
|
||||||
|
}
|
||||||
|
poly.push_back(poly[0]);
|
||||||
|
uvs.push_back({0,0});
|
||||||
|
SetDecalStructure(DecalStructure::LINE);
|
||||||
|
SetDecalMode(DecalMode::WIREFRAME);
|
||||||
|
DrawPolygonDecal(nullptr,poly,uvs,col);
|
||||||
|
SetDecalMode(DecalMode::NORMAL);
|
||||||
|
SetDecalStructure(DecalStructure::FAN);
|
||||||
|
}
|
||||||
|
void FillCircleDecal(vf2d pos,float radius,Pixel col=WHITE) {
|
||||||
|
std::vector<vf2d> poly;
|
||||||
|
std::vector<vf2d> uvs;
|
||||||
|
poly.push_back(pos);
|
||||||
|
uvs.push_back({0,0});
|
||||||
|
for (int i=0;i<CIRCLE_PRECISION;i++) {
|
||||||
|
poly.push_back({pos.x+sinf(2*M_PI/CIRCLE_PRECISION*i)*radius,pos.y+cosf(2*M_PI/CIRCLE_PRECISION*i)*radius});
|
||||||
|
uvs.push_back({0,0});
|
||||||
|
}
|
||||||
|
poly.push_back(poly[1]);
|
||||||
|
uvs.push_back({0,0});
|
||||||
|
DrawPolygonDecal(nullptr,poly,uvs,col);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnUserCreate() override
|
||||||
|
{
|
||||||
|
// Called once at the start, so create things here
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
|
{
|
||||||
|
// called once per frame
|
||||||
|
DrawCircleDecal({50,50},10,BLUE);
|
||||||
|
FillCircleDecal({100,100},20,GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Circles demo;
|
||||||
|
if (demo.Construct(256, 240, 4, 4))
|
||||||
|
demo.Start();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
6222
pixelGameEngine.h
Normal file
9
sig
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
export AUTO_UPDATE=true
|
||||||
|
|
||||||
|
source utils/define.sh
|
||||||
|
|
||||||
|
define PROJECT_NAME "C++ProjectTemplate"
|
||||||
|
define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple"
|
||||||
|
define LANGUAGE "C++"
|
||||||
|
|
||||||
|
source utils/main.sh
|
1
utils/.coauthors
Normal file
@ -0,0 +1 @@
|
|||||||
|
sigonasr2 <sigonasr2@gmail.com>
|
5
utils/.updateDirectories
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Java/
|
||||||
|
C/
|
||||||
|
C++/
|
||||||
|
scripts/
|
||||||
|
utils/
|
26
utils/define.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
export VARS=("")
|
||||||
|
|
||||||
|
export LANGUAGE=""
|
||||||
|
|
||||||
|
function define() {
|
||||||
|
VARS+=("$1")
|
||||||
|
value="${*:2}"
|
||||||
|
eval export "$1"='$value'
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" && $1 != "update" ]]; then
|
||||||
|
source utils/search.sh
|
||||||
|
|
||||||
|
find . -type f -name md5 -delete
|
||||||
|
find . -type f -name filelist -delete
|
||||||
|
|
||||||
|
#Check for hashes
|
||||||
|
FILES=$(cat utils/.updateDirectories)
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
search $f
|
||||||
|
check $f
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Dev build, no checks required."
|
||||||
|
fi
|
5
utils/filelist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.coauthors
|
||||||
|
define.sh
|
||||||
|
main.sh
|
||||||
|
search.sh
|
||||||
|
.updateDirectories
|
28
utils/main.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo " Usage: ./sig <command> {args}"
|
||||||
|
echo ""
|
||||||
|
printf "====\tCurrent Configuration"
|
||||||
|
printf "\t====================="
|
||||||
|
for t in ${VARS[@]}
|
||||||
|
do
|
||||||
|
printf "\n\t%-15s%20s" $t ${!t}
|
||||||
|
done
|
||||||
|
printf "\n====================================================="
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo " Command List:"
|
||||||
|
FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /')
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then
|
||||||
|
DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)"
|
||||||
|
printf "\n\t%-15s%-65s" $f "${DESC:1}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
./$LANGUAGE/scripts/$1.sh "${@:2}"
|
4
utils/md5
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 -
|
||||||
|
main.sh:4e6e9f0650ec790ce2c4364db94f0caa -
|
||||||
|
search.sh:30e1842e9a13452ea883bb6516d28e1c -
|
||||||
|
.updateDirectories:971afb892e8280cb4c9ad43fb72a46a0 -
|
103
utils/search.sh
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
function search() {
|
||||||
|
FILES2=$(ls -A $1 2>/dev/null)
|
||||||
|
for g in $FILES2
|
||||||
|
do
|
||||||
|
if [ -d $1$g ];
|
||||||
|
then
|
||||||
|
echo "$1$g is a directory"
|
||||||
|
search $1$g/
|
||||||
|
else
|
||||||
|
echo "$1$g is a file"
|
||||||
|
if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then
|
||||||
|
if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then
|
||||||
|
SUM=$(md5sum < $1$g)
|
||||||
|
echo "$g:$SUM" >> $1md5
|
||||||
|
fi
|
||||||
|
echo "$g" >> $1filelist
|
||||||
|
else
|
||||||
|
echo " ignoring $g..."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function check() {
|
||||||
|
echo "Check $1"
|
||||||
|
FILES2=$(ls -A $1 2>/dev/null)
|
||||||
|
if [ -f "$1/md5" ];
|
||||||
|
then
|
||||||
|
echo " md5: http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1md5"
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' -s "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1md5" --output /tmp/out
|
||||||
|
cmp -s $1/md5 /tmp/out
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo " Differences detected!"
|
||||||
|
cat /tmp/out
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
IFS=':' read -ra split <<< $line
|
||||||
|
g="${split[0]}"
|
||||||
|
echo "LINE -- $g"
|
||||||
|
if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then
|
||||||
|
if [ -f $1$g ];
|
||||||
|
then
|
||||||
|
if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then
|
||||||
|
echo "++Redownload $1$g..."
|
||||||
|
if [ -f "$1$g" ]; then
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g
|
||||||
|
else
|
||||||
|
echo "===Could not find directory, assuming regular scripts directory exists."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $LANGUAGE/scripts/$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "++==Downloading $1$g..."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < /tmp/out
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f "$1/filelist" ];
|
||||||
|
then
|
||||||
|
echo " filelist: http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1filelist"
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' -s "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1filelist" --output /tmp/out
|
||||||
|
cmp -s $1/filelist /tmp/out
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo " Differences detected!"
|
||||||
|
cat /tmp/out
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
IFS=':' read -ra split <<< $line
|
||||||
|
g="${split[0]}"
|
||||||
|
echo "LINE -- $g"
|
||||||
|
if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then
|
||||||
|
if [ -f $1$g ];
|
||||||
|
then
|
||||||
|
if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then
|
||||||
|
echo "++Redownload $1$g..."
|
||||||
|
if [ -f "$1$g" ]; then
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g
|
||||||
|
else
|
||||||
|
echo "===Could not find directory, assuming regular scripts directory exists."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $LANGUAGE/scripts/$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "++==Downloading $1$g..."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < /tmp/out
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
for g in $FILES2
|
||||||
|
do
|
||||||
|
if [ -d $1$g ];
|
||||||
|
then
|
||||||
|
echo "$1$g is a directory"
|
||||||
|
check $1$g/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|