Game: Goatkeeper


#1

So while we know that we can use Coda to track our goals, I was wondering if we can also use it to shoot some :stuck_out_tongue_winking_eye:

How I came up with it
During the shower I had the crazy idea to make some kind of a space invader game in Coda. But playing around with sliders and cells, I got stuck several times, so I wanted to try something different at first. Why not a goalshooting game? I was using some formulas of the space invade tests and came quickly along. Unfortunately there is no goalkeeper emojy, so I had to find a different “enemy”…

The first challenge: A random mechanism
To even make a game possible, I needed a way to have some kind of “random” odds of winning. I thought, at a goalshooting game, a chance of 1:3 would be good.

But how can you make a game mechanism, when you don’t have “randomize” function?

As an inspiration, I found some articles about pseudorandom formulas. It seemed to be possible to generate such things with timestamps. But since there is no timestamp in Coda, I need to use the seconds of the now() formula.

To get my “1 of 3” odds, I created a table with 60 rows. Each Row represend a second of a minute. I filled them with my numbers 1-2-3-1-2-3-1-2-3-1-2-3… All I needed to do now is a formula, that selects the number by the row of the current second. That is not really “random”, it is just a fixed 1:3 chance every second - but enough for the current state of the game.

How it looks like in Coda (click to expand)

The second challenge: Making things "move"
This was kind of tricky. Since we currenty can’t do repeats and don’t have the ability to insert data with buttons, I had to find another way. Well, again the time functions were my friends here.

I used the checkbox as my trigger and counted the seconds after that. This was my countdown. Every second, the ball should move 1 field further and at second 4, the game should decide if you win or loose.

Counting the seconds (click to expand)

Checking, when the checkboxes are modified last:


(Shot 1 Shot 2 Shot 3 represent the time a shot was made from left, center or right)

If one of the checkboxes is checked, the counter starts to count the seconds (=the position of the ball):

While the seconds now represent the position on the “field” (1 second after click: 1st position, 2 seconds after click: 2nd position…) , I had to create the field and give out the ball-emoji on the right coordinates.

Give out the ball at the right position (click to expand)

Pos1 is the timer of the left column, pos2 center, pos3 right (I better have named it posleft, poscenter, posright :sweat_smile:). At each step, I just check if the timer equals the field of the formula - and if yes, it outputs the ball.
56
So for the 3rd column, 3rd field from the bottom, it is pos3 = 3, and so on…
Setting the formula to all of the “grey” fields, makes the ball move after a click now.

Well, the balls are moving now and the odds are set. Whats next?

The third challenge: Goat or Goal?
At first I needed to check, which column is active right now. Where did the player shot at? I did it by calculating, which button was used last, based on the lastmodified variable I created earlier.

Check the current shot (click to expand)

To make my formulas shorter, I also wanted the current position in one variable (not one for every colum (pos1,pos2,po3), like it was until now):

Check the current position (click to expand)

Now I have three variables:

  • The current position of the ball
  • The current column of the shot
  • The random number (1, 2 or 3) = goat position

Bringing that together, I was able to execute the last, gamechanging row:

The 'winning' formula (click to expand)

This formula basically checks, if the currentpos of the ball is 4 (so, 4 seconds after the click and directly at the realistcly drawn goal). If yes, it checks if the goat (our random number) will be at this row and show it. If not, it checks if this is our current column (the ball).

BONUS Make the audience go crazy
By checking, if the current column is the same as the goat colum, I made this “win” or “loose” indicator.

The 'hands up' formula and winning indicator (click to expand)

Known Issues & limitations by Coda

  • Movement: The game is really slow (in the gif on top it is 200%) since it is based on seconds. A timestamp with miliseconds or something similiar could make this easier.
  • Random: The selfmade random function is a nice workaround but nothing you can really rely on. A rand() function like in excel or programming languages would do the job.
  • Insertion & buttons: My favourite topic. I think I don’t have to mention the creative abilities of buttons or an insertion function :star_struck:

Epilog
I can’t say it often enough. I really love how creative you can get with the possibilites that Coda already provides. And with the community, alpha tests and such a nice staff, I can’t wait so see how it evolves in the future. It was a nice adventure for today. Now back to something more productive :man_technologist:t4:

I’m curious about your thoughts and feedback on that. I will prepare the file for sharing if you want to play around with it on your own.


#2

You should be able to get your own copy of the game with this link (Let me know if sharing in that way doesn’t work):


#3

Really creative use of the emojis @Daniel_Stieber!

You can use the TimeValue() function to get the decimal representation of the given time which is a little more “random” compared to the table with each row representing each second. In the gif below the formula in col1 is simply =TimeValue(now()) and then you can do some basic math to get a number between 0-3. If the generated number equals 0, you could just set the value to 1 but then 1 would be over-weighted in the random set :grin:

44%20AM


#4

@Al_Chen nice, thank you very much, totally missed that! I will try to implement it soon :raised_hands:


#5

@Daniel_Stieber Uhhhhhh… this is insane! I love it!


#6

This is absolutely brilliant!!!
And I totally agree with the three requests of the known issues and limitations part.


#7

@Daniel_Stieber FYI there’s now a random generator built into Coda: random() :grinning:


#8

Awesome news! How did you knew that it exists @Al_Chen?
I can now fully develop the potential of my random daily pick for my Jesse Schell Game design lenses!!
Wooooooow!!
Can be good to make a Tao Tse Ching table also!


#9

I am now working at Coda :slight_smile: , and learned about the formula internally first.


#10

Woooot?! How?! :grinning:
This is great news!
I have to say that the random would need some seed. I would love to change the random value every days instead of every time!