-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69d1b99
Showing
15 changed files
with
35,076 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
std::cout << "Hello World!!" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
|
||
// this function will fail with a ambiguous error in the compiler | ||
int cout() { | ||
return 5; | ||
} | ||
|
||
int main() { | ||
|
||
/* using declaration statements | ||
* using std::cout; | ||
* using std::endl; | ||
* using std::cin; | ||
*/ | ||
|
||
// using directive statement | ||
using namespace std; | ||
|
||
cout << "Please enter any number!: "; | ||
int myNumber = 0; | ||
cin >> myNumber; | ||
cout << "You've entered: " << myNumber << endl; | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
|
||
int additionNum(int firstNumber, int secondNumber, int thirdNumber); | ||
|
||
int main() | ||
{ | ||
std::cout << "Please insert the first number: "; | ||
int firstNumber; | ||
std::cin >> firstNumber; | ||
std::cout << "Please insert the second number: "; | ||
int secondNumber; | ||
std::cin >> secondNumber; | ||
std::cout << "Please insert the third number "; | ||
int thirdNumber; | ||
std::cin >> thirdNumber; | ||
std::cout << "Total is: " << additionNum(firstNumber, secondNumber, thirdNumber) << std::endl; | ||
return 0; | ||
} | ||
|
||
int additionNum(int firstNumber, int secondNumber, int thirdNumber) | ||
{ | ||
return firstNumber + secondNumber + thirdNumber; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <iostream> | ||
|
||
// return type of "void" means the function doesn't return a value so a return satement isn't needed | ||
void secondFunction() { | ||
std::cout << "We're in the secondFunction now!!!" << std::endl; | ||
} | ||
|
||
int myBirthday() { | ||
return 7; | ||
} | ||
|
||
void emptyFunction() { | ||
} | ||
|
||
int pickNumber() { | ||
std::cout << "Pick a #: "; | ||
int selectedNumber; | ||
std::cin >> selectedNumber; | ||
return selectedNumber; | ||
} | ||
|
||
int main() { | ||
std::cout << "We're starting off in the the main() function" << std::endl; | ||
secondFunction(); | ||
std::cout << "We're back in the main() function!!" << std::endl; | ||
std::cout << myBirthday() << " We just got your birthday from the myBirthday function!!" << std::endl; | ||
|
||
// below satement is invalid as you can't pass a void function into cout | ||
// std::cout << emptyFunction() << " We got nothing back! emptyFunction using a void return type" << std::endl; | ||
|
||
int x = pickNumber(); | ||
int y = pickNumber(); | ||
|
||
std::cout << "First # selected was: " << x << " followed by #: " << y << std::endl; | ||
std::cout << "Total: " << x + y << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
|
||
int addNum(int x, int y) { | ||
int total = x + y; | ||
return total; | ||
} | ||
|
||
int doubleNumber(int x) { | ||
int total = x * 2; | ||
return total; | ||
} | ||
|
||
int main () { | ||
std::cout << "#1 please: "; | ||
int firstNum; | ||
std::cin >> firstNum; | ||
std::cout << "#2 please: "; | ||
int secondNum; | ||
std::cin >> secondNum; | ||
std::cout << "Total after addition is : " << addNum(firstNum, secondNum) << std::endl; | ||
std::cout << "#3 please: "; | ||
int thirdNum; | ||
std::cin >> thirdNum; | ||
std::cout << "Total after doubling your number is: " << doubleNumber(thirdNum) << std::endl; | ||
std::cout << "Doubled your original two numbers for you: " << doubleNumber(addNum(firstNum, secondNum)) << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef MATHS_H | ||
#define MATHS_H | ||
|
||
int twoAddition(int firstNumber, int secondNumber); | ||
int twoMultiply(int firstNumber, int secondNumber); | ||
|
||
#endif |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
#include "maths.h" | ||
|
||
/* | ||
* used while learning forward declarations.. moved into maths.h | ||
* int twoAddition(int firstNumber, int secondNumber); | ||
* int twoMultiply(int firstNumber, int secondNumber); | ||
*/ | ||
|
||
int main() | ||
{ | ||
std::cout << "#1: "; | ||
int firstNum; | ||
std::cin >> firstNum; | ||
std::cout << "#2: "; | ||
int secondNum; | ||
std::cin >> secondNum; | ||
std::cout << "Total after addition is: " << twoAddition(firstNum, secondNum) << std::endl; | ||
std::cout << "#1: "; | ||
int thirdNum; | ||
std::cin >> thirdNum; | ||
std::cout << "#2: "; | ||
int fourthNum; | ||
std::cin >> fourthNum; | ||
std::cout << "Total after multiplication is: " << twoMultiply(thirdNum, fourthNum) << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
|
||
int twoAddition(int firstNumber, int secondNumber) | ||
{ | ||
return firstNumber + secondNumber; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
|
||
int twoMultiply(int firstNumber, int secondNumber) | ||
{ | ||
return firstNumber * secondNumber; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Practice Objects/Constructors</title> | ||
<meta charset="UTF-8" /> | ||
|
||
<style type="text/css"> | ||
canvas { border: 1px solid black; } | ||
|
||
#centerCanvas { | ||
width: 800px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
textarea { | ||
resize: none; | ||
width: 40px; | ||
height: 15px; | ||
text-align: center; | ||
} | ||
</style> | ||
|
||
<script> | ||
var objectArray = new Array(); | ||
var textArea; | ||
|
||
function mainDraw() { | ||
requestAnimationFrame(mainDraw); | ||
for (x = 0; x < objectArray.length; x++) { | ||
objectArray[x].draw(); | ||
} | ||
} | ||
|
||
function Unit(x, y, radius) { | ||
this.x = x; | ||
this.y = y; | ||
this.radius = radius; | ||
} | ||
|
||
Unit.prototype = { | ||
draw: function() { | ||
ctx.beginPath(); | ||
ctx.arc(this.x, this.y, this.radius, 0, 2 * Math.PI); | ||
ctx.fill(); | ||
} | ||
} | ||
|
||
// going this route just to learn Object Prototypes, wouldn't do it this way normally (wouldn't track Objects) | ||
function mouseEvents() { | ||
var randomX = Math.floor(Math.random() * (canvas.width - 10) + 10); | ||
var randomY = Math.floor(Math.random() * (canvas.height - 10) + 10); | ||
var randomRadius = Math.floor(Math.random() * (30 - 5) + 5); | ||
objectArray.push(new Unit(randomX, randomY, randomRadius)); | ||
textArea = document.getElementById("currentCount"); | ||
textArea.value = objectArray.length | ||
} | ||
|
||
function clearingArray() { | ||
objectArray.length = 0; | ||
ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
textArea.value = objectArray.length; | ||
} | ||
|
||
function init() { | ||
var canvas = document.getElementById("canvas"); | ||
ctx = canvas.getContext("2d"); | ||
window.onmousedown = mouseEvents; | ||
requestAnimationFrame(mainDraw); | ||
} | ||
</script> | ||
|
||
</head> | ||
<body onload="init()"> | ||
<div id="centerCanvas"> | ||
<canvas id="canvas" width="800" height="600"></canvas> | ||
<button id="clear" type="button" onclick="clearingArray()" align="right"> | ||
Flush Array of current Objects | ||
</button> | ||
<textarea id="currentCount"></textarea> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<html> | ||
<head> | ||
<title>Basic Three.JS</title> | ||
<style> | ||
body { margin: 0; } | ||
canvas { width: 100%; height: 100%; } | ||
</style> | ||
</head> | ||
<body> | ||
<input type="range" id="zSlider" min="75" max="300" step="1" value="100"> | ||
<select id="colors"> | ||
<option value="red">Red</option> | ||
<option value="blue">Blue</option> | ||
<option value="black">Black</option> | ||
</select> | ||
<script type="application/javascript" src="three.js"></script> | ||
<script type="application/javascript" src="stats.min.js"></script> | ||
<script> | ||
|
||
var scene, camera, renderer; | ||
var geometry, material, sphere; | ||
var zValue, stats; | ||
|
||
init(); | ||
animate(); | ||
|
||
function init() { | ||
|
||
scene = new THREE.Scene(); | ||
zVal = document.getElementById("zSlider"); | ||
|
||
stats = new Stats(); | ||
stats.setMode(0); | ||
document.body.appendChild(stats.domElement); | ||
stats.domElement.style.position = "absolute"; | ||
stats.domElement.style.right = "0px"; | ||
stats.domElement.style.top = "0px"; | ||
|
||
// PerspectiveCamera attributes: (Field of View, Aspect Ratio, near, far (clipping plane)) | ||
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | ||
|
||
// three.js come with other renderers as fallback for older browsers that don't support WebGL (find more info) | ||
// alpha is used for a transparent background | ||
// you can set the defualt transparency color using: renderer.setClearColor(0x000000, 0); | ||
renderer = new THREE.WebGLRenderer({ | ||
alpha: true | ||
}); | ||
|
||
renderer.setSize(window.innerWidth, window.innerHeight); | ||
|
||
// add the element to our HTML document | ||
document.body.appendChild(renderer.domElement); | ||
|
||
geometry = new THREE.SphereGeometry(35, 30, 30); | ||
|
||
material = new THREE.MeshBasicMaterial({ | ||
color: 0x000000, | ||
wireframe: true | ||
}); | ||
|
||
sphere = new THREE.Mesh(geometry, material); | ||
scene.add(sphere); | ||
|
||
camera.position.z = 100; | ||
|
||
zSlider.onchange = function changeZ() { | ||
camera.position.z = this.value; | ||
} | ||
|
||
colors.onchange = function changeColor() { | ||
switch (colors.value) { | ||
case "red": | ||
sphere.material.color.setHex(0xFF0000); | ||
break; | ||
case "blue": | ||
sphere.material.color.setHex(0x0000FF); | ||
break; | ||
case "black": | ||
sphere.material.color.setHex(0x000000); | ||
break; | ||
} | ||
} | ||
|
||
} | ||
|
||
function animate() { | ||
requestAnimationFrame(animate); | ||
sphere.rotation.y += 0.1; | ||
renderer.render(scene, camera); | ||
stats.update(); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.