Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Commit

Permalink
(Asset) update DogCat
Browse files Browse the repository at this point in the history
  • Loading branch information
Torbuntu committed Jun 8, 2019
1 parent d5e7ff4 commit 4baa9c2
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 43 deletions.
2 changes: 1 addition & 1 deletion assets/Programs/DogCat/Code/Menu.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
71 changes: 56 additions & 15 deletions assets/Programs/DogCat/Code/main.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,66 @@ 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")
p.setState(3)//3 jumping
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)


Expand All @@ -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++
}
}
}

26 changes: 6 additions & 20 deletions assets/Programs/DogCat/Code/player.groovy
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -83,8 +66,11 @@ class Player{
y += vy
x += vx

vx = 0


if(y>= 160) {
x=40
x=80
y=20
}
}
Expand Down
20 changes: 13 additions & 7 deletions assets/Programs/DogCat/Maps/map.tmx
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.0" orientation="orthogonal" renderorder="right-down" width="16" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="1">
<map version="1.2" tiledversion="1.2.0" orientation="orthogonal" renderorder="right-down" width="40" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="7" nextobjectid="1">
<tileset firstgid="1" name="Sprites" tilewidth="32" tileheight="32" tilecount="100" columns="10">
<image source="../Sprites/Sprites.png" width="320" height="320"/>
<tile id="42">
<animation>
<frame tileid="40" duration="1000"/>
<frame tileid="41" duration="400"/>
</animation>
</tile>
<tile id="80">
<animation>
<frame tileid="97" duration="700"/>
<frame tileid="98" duration="700"/>
</animation>
</tile>
</tileset>
<layer id="4" name="Tile Layer 1" width="16" height="5">
<layer id="6" name="Tile Layer 1" width="40" height="5">
<data encoding="csv">
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
</data>
</layer>
</map>
Binary file modified assets/Programs/DogCat/Sprites/Sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4baa9c2

Please sign in to comment.