diff --git a/assets/Programs/DogCat/Code/Menu.groovy b/assets/Programs/DogCat/Code/Menu.groovy index 9fd3f60b..2c8935ae 100644 --- a/assets/Programs/DogCat/Code/Menu.groovy +++ b/assets/Programs/DogCat/Code/Menu.groovy @@ -3,7 +3,7 @@ class Menu { boolean activeMenu = true def drawMenu(screen){ - screen.text("Press ENTER to start!", 70, 50, 32) + screen.text("Press ENTER to start!", 45, 50, 32) screen.sprite(0, 120, 80, 2) } } diff --git a/assets/Programs/DogCat/Code/main.groovy b/assets/Programs/DogCat/Code/main.groovy index da683544..0e5ce395 100644 --- a/assets/Programs/DogCat/Code/main.groovy +++ b/assets/Programs/DogCat/Code/main.groovy @@ -18,29 +18,44 @@ class DogCat extends leikr.Engine { return } p.setState(0) - if(key("Left") && !solid(p.x+10, p.y+16)){ - if(p.x+12 < 0){ - p.x = 220 - mapX = 0 - } + if(key("Left") && !solid(p.x+10, p.y+16) && p.x+2 > 0){ + p.vx = -1.5f p.setFace(true) if(key("L-Shift")) { p.setState(2) + p.vx = -2 }else{ p.setState(1) } + if(p.x < 80 && mapX < 0){ + if(key("L-Shift")){ + mapX = mapX +2 + }else{ + mapX++ + } + p.vx + p.vx = 0 + } + } if(key("Right") && !solid(p.x+20, p.y+16)){ - if(p.x+20 > 240) { - p.x = -12 - mapX = 8 - } + p.vx = 1.5f p.setFace(false) if(key("L-Shift")){ p.setState(2)//2 running + p.vx = 2 }else{ p.setState(1)//1 walking } + + if(p.x + p.vx > 120) { + if(key("L-Shift")){ + mapX = mapX - 2 + }else{ + mapX-- + } + p.vx = 0 + } } if(key("Up") && p.vy == 0 && !p.jumping){ sfx("jump") @@ -48,11 +63,21 @@ class DogCat extends leikr.Engine { p.vy = -0.5f p.jumping = true } + if(solid(p.x+12,p.y+32) || solid(p.x+20, p.y+32)){ p.onGround() }else{ p.falling() } + + //shroom + if(shroom(p.x+12,p.y+32) || shroom(p.x+20, p.y+32) && p.jumping) { + p.setState(3)//3 jumping + p.vy = -2f + p.jumping = true + } + coin(p.x+12, p.y+15) + coin(p.x+20, p.y+15) p.update(delta) @@ -65,20 +90,36 @@ class DogCat extends leikr.Engine { return } bgColor(6) - map(0, 0, mapX, mapY, 240, 160) + map(mapX, mapY) p.draw(screen) - drawColor(8) - line((int)(p.x+12), (int)(p.y+32), (int)(p.x+20), (int)(p.y+32)) + + text("Coins: " + p.coin, 0,8,1) } //End engine methods //Start Helper methods def solid(x,y){ - float mx = (x)/32 + mapX - float my = (y)/32 + mapY - int id = mapGet((int)mx,(int)my) + float mx = (x - mapX) /32 + float my = (y - mapY) /32 + int id = mapGet(floor(mx),floor(my)) return ( id > 81 && id <= 97) } + + def shroom(x,y){ + float mx = (x-mapX)/32 + float my = (y-mapY)/32 + int id = mapGet(floor(mx), floor(my)) + return id == 30 + } + def coin(x,y){ + float mx = (x-mapX)/32 + float my = (y-mapY)/32 + int id = mapGet(floor(mx), floor(my)) + if(id == 43) { + mapSet(floor(mx), floor(my), -1) + p.coin++ + } + } } diff --git a/assets/Programs/DogCat/Code/player.groovy b/assets/Programs/DogCat/Code/player.groovy index dff21f53..3420f871 100644 --- a/assets/Programs/DogCat/Code/player.groovy +++ b/assets/Programs/DogCat/Code/player.groovy @@ -1,5 +1,5 @@ class Player{ - float x = 40, y = 20, vx = 0, vy = 0, gv = 2 + float x = 80, y = 20, vx = 0, vy = 0, gv = 2, coin = 0 def idleAnimation, walkingAnimation, runningAnimation, jumpingAnimation @@ -57,24 +57,7 @@ class Player{ jumpTime = 12 jumping = false } - vx = 0 - switch(state){ - case 1: - if(facing){ - vx = -1.5 - }else{ - vx = 1.5 - } - break - case 2: - if(facing){ - vx = -2 - }else{ - vx = 2 - } - break - } - + if(!ground && !jumping){ vy += 3 state = 3 @@ -83,8 +66,11 @@ class Player{ y += vy x += vx + vx = 0 + + if(y>= 160) { - x=40 + x=80 y=20 } } diff --git a/assets/Programs/DogCat/Maps/map.tmx b/assets/Programs/DogCat/Maps/map.tmx index 2b2f56e7..c72cf36b 100644 --- a/assets/Programs/DogCat/Maps/map.tmx +++ b/assets/Programs/DogCat/Maps/map.tmx @@ -1,7 +1,13 @@ - + + + + + + + @@ -9,13 +15,13 @@ - + -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,30,29,0,0,0, -0,0,0,0,0,0,0,0,39,0,95,96,96,97,0,0, -0,40,0,0,39,0,29,30,83,81,81,81,81,81,81,85, -84,84,84,81,84,81,84,84,90,100,100,100,100,100,100,92 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,30,29,43,0,0,0,0,0,0,0,0,43,0,0,39,43,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,43,0,0,0,0,0,43,39,0,95,96,96,97,0,39,43,0,0,0,0,43,83,81,81,85,43,0,0,0,0,0,0,0,0,0, +0,0,0,0,43,40,43,0,39,0,29,30,83,81,81,81,81,81,81,85,40,43,39,0,0,30,86,100,100,88,30,0,43,43,29,39,0,0,0,0, +81,81,81,81,84,84,84,81,84,81,84,84,90,100,100,100,100,100,100,92,93,84,85,0,83,89,90,100,100,92,93,84,96,96,84,84,81,81,81,81 diff --git a/assets/Programs/DogCat/Sprites/Sprites.png b/assets/Programs/DogCat/Sprites/Sprites.png index 311621c5..d91a36ae 100644 Binary files a/assets/Programs/DogCat/Sprites/Sprites.png and b/assets/Programs/DogCat/Sprites/Sprites.png differ