Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
A jam submission

Lil Monk CooksView game page

Cooking rice; when not meditating. LCD Game
Submitted by Postmodestie — 11 hours, 19 minutes before the deadline
Add to collection

Play game

Lil Monk Cooks's itch.io page

Results

CriteriaRankScore*Raw Score
Gameplay#32.9213.200
Winner#72.7393.000
Graphics#82.9213.200
Sound#92.3732.600

Ranked from 5 ratings. Score is adjusted from raw score by the median number of ratings per game in the jam.

Source Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class M : MonoBehaviour {

//Sounds
public AudioSource audio;
public AudioSource audioBell;
public AudioClip soundTick, soundBell, soundScore, soundLoss, soundGain, soundGameover;

//World

public const int SCORE_INCREMENT = 1;
public const float TICK_INITIAL = 0.5f;
public const float TICK_DECREMENT = 0.05f;

public bool gameOver;
public int medi;
public int score;
public int highscore;
public int lives;
public bool doubleGain;
public int mediIncrease;


public float tickTime;
public float tick = TICK_INITIAL;
public float wait;
public float animFoamSpeed;

//GameScreen

public enum GameState {
Ready, // AI Demo Mode
Running,
Paused,
GameOver
}
public enum InGameState {
Play,
LifeLoss,
LifeGain,
Meditate
}

//States

GameState state;
InGameState inState;

public int monkPos;
public int stirPos, stirOldPos;
public int[] foamHeight; // Height of all 12 foams
public int[] animfoamHeight; // Animated Height of all 12 foams
public int[] foamTick; // current foam tick
int[] foamGrowthTick; // ticks necessary for foam to grow. NOT necessary, but later for random speeds...

//GFX
public SpriteRenderer[] monk;
public SpriteRenderer[] stir;
public Transform[,] foamObj; // all 12 x 3 foam objects
public SpriteRenderer[,] foam; // all 12 x 3 foam sprites for convenience
public Transform[] foamPhysicalPos; // helper obects for foam base position
public Transform foamPrefab;
public SpriteRenderer[] life;
public SpriteRenderer bell, bell2;

// Text
public Text textScore;
public Text textLegend;



// Use this for initialization
void Start () {

state = new GameState();

foamHeight = new int[12];
animfoamHeight = new int[12];
foamTick = new int[12];
foamGrowthTick = new int[12];

foam = new SpriteRenderer[12,3];
foamObj = new Transform[12,3];

for (int p = 0; p < 12; p++) {
for (int h = 0; h < 3; h++) {

foamObj [p, h] = Instantiate (foamPrefab, foamPhysicalPos[p].position + new Vector3(0, h * 0.2f, 0), Quaternion.identity);
foam [p, h] = foamObj [p, h].GetComponent<SpriteRenderer> ();
// foam [p, h].enabled = true;
}
}

//Speed of foam growth
for (int x = 0; x < 12; x++) {
foamGrowthTick[x] = 5;

//test
// foamHeight[x] = 3;
}

highscore = PlayerPrefs.GetInt("Highscore", 0);
textScore.text = highscore.ToString();
// NewGame ();
}

// Update is called once per frame
void Update () {

if (state == GameState.Ready) {
if (Input.anyKey && wait < Time.time) {
NewGame ();
}
}

else if (state == GameState.Running) {

if (inState == InGameState.Play) {


//Tick Loop
tickTime += Time.deltaTime;

if (tickTime > tick) {
tickTime -= tick;

if (medi == 1) {
// audio.clip = soundBell;
audioBell.Play ();

if (bell.enabled == true) {
bell.enabled = false;
}
else
bell.enabled = true;
if (bell2.enabled == true) {
bell2.enabled = false;
}
else
bell2.enabled = true;
}

//advance game
UpdateFoam ();
}

//Control
GameInput ();
// process Player input
DrawFoam ();
DrawMonk ();
UpdateStir ();

if (medi == 1 && wait < Time.time) {
ProcessLifeLoss ();
// break;
}

if (monkPos == 3) {
ProcessMedi ();
// break;
}
} else if (inState == InGameState.Meditate) {
if (wait < Time.time) {
// wait = 0;
// score += 5;
// textScore.text = score.ToString();
monkPos = 2;
inState = InGameState.Play;
}
}
else if (inState == InGameState.LifeLoss) {

//Tick Loop
tickTime += Time.deltaTime;

if (tickTime > tick) {
tickTime -= tick;
if (monk [monkPos].enabled == true) {
monk [monkPos].enabled = false;
} else {
monk [monkPos].enabled = true;
}
}


// wait for continue of play
if (wait < Time.time) {
// Debug.Log (wait);
if (gameOver == false) {
inState = InGameState.Play;
ResetFoamHeight ();
} else {
wait = Time.time + 2;
state = GameState.Ready;
textLegend.gameObject.SetActive(true);
highscore = score;
textScore.text = highscore.ToString ();
}
monk [monkPos].enabled = true;
}
}

} else if (state == GameState.Paused) {
if (Input.GetKeyUp ("p")) {
state = GameState.Running;
}
}
}

void OnDisable () {
PlayerPrefs.SetInt("Highscore", highscore);
}

void NewGame() {
monkPos = 0;
stirPos = 1;
gameOver = false;
medi = 0;
state = GameState.Running;
inState = InGameState.Play;
score = 0;
textScore.text = score.ToString();
lives = 3;
DrawLives ();
bell.enabled = false;
bell2.enabled = false;
ResetFoamHeight ();
doubleGain = false;
mediIncrease = 0;
textLegend.gameObject.SetActive(false);
}

void DrawLives() {
for (int x = 0; x < 3; x++) {
if (lives > x) {
life [x].enabled = true;
} else {
life [x].enabled = false;
}
}
}

void ProcessMedi () {
inState = InGameState.Meditate;
wait = Time.time + 5;
medi = 0;
bell.enabled = false;
bell2.enabled = false;
ResetFoamHeight ();
DrawFoam ();
}

void ProcessLifeLoss () {
inState = InGameState.LifeLoss;
lives--;
doubleGain = false;
audio.clip = soundLoss;
audio.Play ();

if (lives > 0) {
wait = Time.time + 3;
} else {
gameOver = true;
audio.clip = soundGameover;
audio.Play ();
wait = Time.time + 5;
}
medi = 0;
DrawLives ();
// ResetFoamHeight ();
bell.enabled = false;
bell2.enabled = false;
// DrawFoam ();
}

void UpdateFoam() {

for (int p = 0; p < 12; p++) {

//Update foam grow time
foamTick[p]++;

// Grow foam
if (foamTick[p] > foamGrowthTick[p]) {
foamTick [p] = 0;
foamHeight [p]++;
audio.clip = soundTick;
audio.Play ();

//temp: make life loss
if (foamHeight[p] > 3) {

ProcessLifeLoss ();
break;
}
}
}
// for (int p = 0; p < 12; p++) {
// for (int h = 0; h < 3; h++) {
//
// }
// }

}

void UpdateStir() {
// stir
if (monkPos < 3 && stirPos != stirOldPos) {
int s = stirPos + monkPos * 4;
// Debug.Log (s);

//if stir not middle
if (s != 1 && s != 5 && s != 9) {

// for (int pos = s; pos <= s + 1; pos++) {
if (foamHeight [s] > 0) {
foamHeight [s]--;
foamTick [s] = 0;
audio.clip = soundScore;
audio.Play ();
score++;
if (score % 300 == 0) {
if (lives < 3) {
lives++;
audio.clip = soundGain;
audio.Play ();
} else {
doubleGain = true;
audio.clip = soundGain;
audio.Play ();
}
}
else if (score % 100 == 0 && tick - TICK_DECREMENT > 0) {
mediIncrease += 15;
tick -= TICK_DECREMENT;
// Debug.Log ("tick: " + tick);
} else if (score % (30 + mediIncrease) == 0) {
medi = 1;
bell.enabled = true;
wait = Time.time + 3;
}
if (doubleGain)
score++;
textScore.text = score.ToString();
}
if (foamHeight [s + 1] > 0) {
foamHeight [s + 1]--;
foamTick [s + 1] = 0;
}

//stir middle - decrease foamTick for whole cauldron
} else {
for (int pos = s - 1; pos <= s + 1; pos++) {
if (foamTick [pos] > 0) {
foamTick [pos]--;
}
}
}
// DrawFoam ();
stirOldPos = stirPos;
}
}

void DrawFoam() {

for (int p = 0; p < 12; p++) {
for (int h = 0; h < 3; h++) {

if (foamHeight [p] > h) {
foam [p, h].enabled = true;
// AnimFoam ();
} else {
foam [p, h].enabled = false;
}
}
}

}

void AnimFoam() {
Debug.Log (animFoamSpeed);

if (animFoamSpeed < Time.time) {
animFoamSpeed = Time.time + 0.2f;

for (int p = 0; p < 12; p++) {
for (int h = 0; h < 3; h++) {
if (animfoamHeight [p] < foamHeight [p]) {
animfoamHeight [p]++;
if (foam [p, h].enabled == true)
foam [p, h].enabled = false;
else
foam [p, h].enabled = true;
}
else if (animfoamHeight [p] == foamHeight [p]) {
animfoamHeight [p] = 0;
// foam [p, h].enabled = false;
}
}
}

}
}

void DrawMonk() {

//draw monk + stir

for (int x = 0; x < 4; x++) {
if (monkPos == x) {

//monk pos
monk [x].enabled = true;

// stir pos
for (int s = 0; s < 9; s++) {
if (monkPos < 3) {
if (stirPos + x * 3 == s) {
stir [s].enabled = true;
} else {
stir [s].enabled = false;
}
}
else {
stir [s].enabled = false;
}
}
// disable monk sprites
} else {
monk [x].enabled = false;
}
}
}

void ResetFoamTicks() {
for (int x = 0; x < 12; x++) {
foamTick[x] = 0;
}
}
void ResetFoamHeight() {
for (int x = 0; x < 12; x++) {
foamHeight[x] = 0;
}
ResetFoamTicks ();
}



void GameInput() {

if (Input.GetKeyUp ("p")) {
state = GameState.Paused;
}

// monk moves
if (Input.GetKeyUp ("a")) {
if (monkPos > 0) {
monkPos--;
stirPos = stirOldPos = 1;
audio.clip = soundTick;
audio.Play ();
}
}
else if (Input.GetKeyUp ("d")) {
//monk can switch between cauldrons. If medi = 1 can go to meditation position
if (monkPos < 2 + medi) {
monkPos++;
stirPos = stirOldPos = 1;
audio.clip = soundTick;
audio.Play ();
}
}

// stir moves
if (Input.GetKeyUp ("q") || Input.GetKeyUp("left")) {
if (stirPos > 0) {
stirOldPos = stirPos;
stirPos--;
// audio.clip = soundTick;
// audio.Play ();
}
}
else if (Input.GetKeyUp ("e") || Input.GetKeyUp("right")) {
if (stirPos < 2) {
stirOldPos = stirPos;
stirPos++;
// audio.clip = soundTick;
// audio.Play ();
}
}
}

void AiInput() {

}
}

Leave a comment

Log in with itch.io to leave a comment.

Comments

Developer (2 edits)


Thought I'll post a screenshot of the updated version for mobile.. background optional.

If anyone is interested in trying it out, I can put up a download link of a developer version in the next few days..

Submitted(+1)

This is an interesting game. I really like it.

At first I was so focused on stirring, that I didn't hear the bell ^^

Developer

Haha! Thanks! Now that I think of it, that is indeed a good metaphor for life: one is so occupied by living (stirring), that it can make you forget to just be still in your mind for a second! :D

Submitted(+1)

This was exactly what I thought, but I was not sure whether this effect was intended or not, since it fits the idea of playing a monk in the game ;)

Developer

Purely accidential! And it needed your comment for me to realise it! :)

Submitted(+1)

the difficutly was quite high for me :) but still liked it. Would be fun to play on a physical handheld

Developer

Thanks! I guess it shows that I played through almost all Game&Watch games recently! ;-)

I've already an Android version running, but have to find the right button layout. One idea I just had reading your comment: for stirring it would be cool not to press a button but to have a sliding input, where you move your finger left - right: I should research if this is possible with 80/90ties tech!

Submitted

yes :) I think in that time it may be a small joystick or a rocking(?) switch like here (but just left/right)

Developer

Yes the rocking thing springs to mind, but I thought more of touch-sensitive cell, where you can really slide between the two inputs...