Merge branch 'master' of github.com:rsninja722/LudumDare46

This commit is contained in:
Evan Pratten 2020-04-18 20:14:23 -04:00
commit d6ff3c21bd
No known key found for this signature in database
GPG Key ID: 93AC7B3D071356D3
7 changed files with 101 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -3,7 +3,9 @@ var page_preloader = new Preloader();
page_preloader.show(true);
images = [
""
"assets/images/",
"level.png",
"level_2.png"
];
audio = [
@ -18,13 +20,14 @@ var globalStates = {
end: 4,
building: 5
};
var globalState = globalStates.playing;
var globalState = globalStates.titleScreen;
function update() {
switch (globalState) {
// title screen
case globalStates.titleScreen:
handleTitleScreen();
break;
// level transition
case globalStates.levelTransition:
@ -60,7 +63,7 @@ function draw() {
switch (globalState) {
// title screen
case globalStates.titleScreen:
drawTitleScreen();
break;
// level transition
case globalStates.levelTransition:
@ -68,8 +71,9 @@ function draw() {
break;
// playing
case globalStates.playing:
camera.zoom = 2;
camera.zoom = 1;
drawWorldBlocks();
imgIgnoreCutoff(sprites.level_2,0,0,0,4,4);
player.draw();
break;
// paused
@ -82,6 +86,7 @@ function draw() {
break;
//building - to be used only in development
case globalStates.building:
buildDraw();
break;
}

View File

@ -37,7 +37,8 @@ Player.prototype.update = function() {
// select
if (this.shouldMoveLeg) {
this.moveLeg();
if(mousePress[0]) {// if (collidingWithWorld({ x: curLeg.x2, y: curLeg.y2, w: 4, h: 4 })) {
if(mousePress[0] && collidingWithWorld({x: curLeg.x2, y: curLeg.y2, w:8, h:8})) {
if (this.legSelected === "R") {
this.leftLeg.angle += pi;
} else {
@ -95,17 +96,19 @@ Player.prototype.moveLeg = function(){
// move selected leg towards mouse
// console.log(curLeg.angle.toPrecision(5),pointTo(curLeg,target).toPrecision(5));
curLeg.angle = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed);
var angleDif = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed) - curLeg.angle;
curLeg.angle += angleDif;
// var angle = pointTo(curLeg,target);
curLeg.x2 = curLeg.x + curLeg.len * Math.cos(curLeg.angle);
curLeg.y2 = curLeg.y + curLeg.len * Math.sin(curLeg.angle);
// Collision
if(collidingWithWorld({x:curLeg.x2,y:curLeg.y2,w:4,h:4})){
if(collidingWithWorld({x:curLeg.x2,y:curLeg.y2,w:2,h:2})){
this.collided = true;
curLeg.x2 = lastX;
curLeg.y2 = lastY;
curLeg.angle -= angleDif;
return 0;
}
@ -243,5 +246,5 @@ function distanceToLineSegment(lx1, ly1, lx2, ly2, px, py) {
var player = new Player(500,100);
var player = new Player(500,-100);

View File

@ -0,0 +1,81 @@
var titleScreenState = "main"
var cursor = mousePos;
var timer = 0;
function handleTitleScreen(){
switch(titleScreenState){
case("main"):
handleMainScreen();
break;
case("credits"):
handleCredits();
break;
}
}
function handleMainScreen(){
if(timer > 20){
if(rectpoint({x:415, y:200, w: 300, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
globalState = globalStates.playing;
timer = 0;
}
if(rectpoint({x:415, y:550, w: 300, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
titleScreenState = "credits"
timer = 0;
}
}else{
timer++;
}
}
function handleCredits(){
if(timer > 20){
if(rectpoint({x:395, y:550, w: 140, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
titleScreenState = "main";
timer = 0;
}
}else{
timer++;
}
}
function drawTitleScreen(){
if(titleScreenState === "main"){
text("GAME TITLE HERE", 50, 50, "green", 8, 1000);
rect(415, 200, 300, 50, "green");
text("Play!", 355, 185, "white", 5, 150);
rect(415, 550, 300, 50, "green");
text("Credits", 325, 535, "white", 5, 150);
}
if(titleScreenState === "credits"){
text("CREDITS", 250, 50, "green", 8, 300);
rect(395, 550, 140, 50, "green");
text("Back", 345, 535, "white", 5, 150);
}
}

View File

@ -12,7 +12,7 @@ class block {
}
// create blocks
var blockData = [631,407,590,461,316,427,40,420,277,447,40,380,238,466,40,340,199,486,40,300,161,507,40,260,121,527,40,220,82,545,40,180,-407,561,1300,150,-1000,350,120,570,-281,483,120,70,-191,481,35,35,878,145,95,776,734,172,195,76];
var blockData = [942,-184,94,507,942,191,94,507,372,411,1054,67,-316,369,1214,152,-38,270,86,107,-166,243,125,127,238,320,45,127,273,284,45,127,309,248,45,127,341,215,45,127,377,179,45,127,412,143,45,127,450,107,45,127,603,105,285,196,777,27,285,196,-989,23,175,959,154,-441,2555,51];
for (let i = 0, l = blockData.length; i < l; i += 4) {
collisionRects.push(new block(blockData[i], blockData[i + 1], blockData[i + 2], blockData[i + 3]));
}

View File

@ -37,7 +37,7 @@
<script src="assets/js/utils.js"></script>
<!-- Everything Else -->
<!-- <script src="assets/js/world/build.js"></script> -->
<script src="assets/js/world/build.js"></script>
<script src="assets/js/world/level.js"></script>
<script src="assets/js/player/leg.js"></script>
@ -46,7 +46,7 @@
<script src="assets/js/playing/playing.js"></script>
<!-- <script src="assets/js/titleScreen/titleScreen.js"></script> -->
<script src="assets/js/titleScreen/titleScreen.js"></script>
<script src="assets/js/UI/ui.js"></script>
<!-- Webpage -->