Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411713 Posts in 69402 Topics- by 58450 Members - Latest Member: FezzikTheGiant

May 21, 2024, 11:03:09 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogs1GAM: Match 3 Unity exercise
Pages: [1]
Print
Author Topic: 1GAM: Match 3 Unity exercise  (Read 406 times)
internationalfish
Level 0
***


View Profile
« on: September 09, 2016, 01:50:28 AM »

Up front apologies if this is abnormal, but I didn't see any precedent regarding not logging short-term/super-basic jam projects here.

While considering how to approach OneGameAMonth, I decided I'd rip the basic elements out of several reasonably simple game ideas to come up with obnoxiously basic game ideas -- essentially single game mechanics out of which I intend to create one game a month using Unity. My intention is to target Android with all of them, as that's the platform I'm mainly interested in working with.

Up first: Match 3.

The original concept had an accelerometer element, so that will be the next mechanic to get some love, but for now I'm stuck with just plain old Match 3. Well, at least nothing excessively complicated that deviates too far from that mechanic. Amusingly, I actually saw a girl on the train today playing pretty much what I'd come up with before, so at least I can be pretty sure I'm not sitting on the Next Big Thing.

Out of a few ideas, the one I figured would be at least a little novel was altering the direction new tiles 'fell' in from each time a match was made. I later realized this pretty much just means rotating the game board, which... shock and awe! Also been done. Oh well. I think I'm going to keep my original idea, as it's subtly different in that the player's view is fixed.

Meh, it's just practice anyway. Smiley



I sketched out the main gameplay, using my amazing Programmer Art Skills (you'd never know I actually used to be a decent artist... oh well) for kind of a concrete view. While the goal is really just to build and release simple games, I think this will be good for at least a few fun moments when several coincidental matches result in the usual waterfall effect with an added rotation gimmick.

I figured laying out the actual goals for this exercise would be appropriate, so here's a list. I love, love, love lists. So I put lists inside my lists, so I could list while I listed. It was good.

  • Learn dynamic scene sizing and fixed orientation (for Android) in Unity.
    • Consider trying to support centering the game board on wider aspects and shoving it off to the side for lower ones.
  • UI: Title screen with Start button and timer/turn count toggle; game screen; score summary screen.
    • Look into whether multiple scenes is best practice for Unity here.
  • Clear UI indicators for game mechanics
    • Including typical snap-back of partially-dragged tiles.
    • Game turn count/timer and score display.

Wish me luck!
« Last Edit: September 12, 2016, 06:21:05 AM by internationalfish » Logged

internationalfish
Level 0
***


View Profile
« Reply #1 on: September 12, 2016, 06:20:48 AM »

Today's time on the project was marked/marred by things that perhaps should've been obvious. I've discovered that, while a lot of the scripting is pretty easy and the UI makes a lot of otherwise very complex things somewhere between easy and hilariously trivial, there are some very important basics that I clearly don't get the way I need to. Primarily: 2D coordinates. Which feels a little pathetic.

On the plus side, I managed to work around that, and there's a pretty, pretty picture to prove it!



...unfortunately, it's utter crap. Sorry, that would be my first attempt at capturing frames from a running Unity project at a frame rate appropriate for an animated GIF. It clearly did not work well. This actually looks pretty freaking slick.

But there's at least a few important things that have been finished.

  • Tiles are being created programmatically from Unity prefabs.
  • Their animations and animation transitions work.
  • The whole thing starts rather orderly but gets wonderfully chaotic very quickly.
  • Pretty colors; pretty random.

The sprites come from Oryx' Sci-Fi sprite pack, which is awesome, but I think I've pretty much spammed Oryx links enough from my posts (despite no affiliate linking, wink wink, nudge nudge). Plus, it googles well, so if you're interested, by all means check it out.

I'd like to use the UI elements from that as well, but that part has been... slightly trickier. Part of it is, as you may be able to see from the GIF, the import is crap. Which seems to be due to a combination of me not having the right import settings and me not having the right camera/canvas/whatever settings. So largely a whole lot of me not knowing what the hell I'm doing.

This is unlikely to be interesting to anyone, but just in case, this is my newbish approach to building the little tech demo presented in the gif above.

Code:
using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour {
public GameObject[] cubes;

void SpawnRandomCube(Vector3 position) {
GameObject cube;

cube = (GameObject)Instantiate (cubes[Random.Range(0, cubes.Length)]);
cube.transform.position = position;
StartCoroutine(Respawn (cube));
}

IEnumerator Respawn(GameObject cube) {
yield return new WaitForSeconds (Random.Range (1, 10));

Animator animator = cube.GetComponent ();
animator.SetTrigger ("CubePop");

yield return new WaitForSeconds (0.5f);
cube.SetActive(false);

yield return new WaitForSeconds (0.3f);

SpawnRandomCube (cube.transform.position);
Destroy (cube);
}

void Start () {
for (float x = -0.8f; x <= 0.8f; x += 0.25f) {
for (float y = -0.75f; y <= 0.85f; y += 0.25f) {
SpawnRandomCube (new Vector3 (x, y, 0f));
}
}
}
}

MonoDevelop uses hard tabs. God, I have so much to teach it.
« Last Edit: September 12, 2016, 06:39:48 AM by internationalfish » Logged

roguesleipnir
Level 0
**



View Profile
« Reply #2 on: September 12, 2016, 06:34:26 AM »

Your gif's not working. It seems to be linked to localhost. Try hosting it online.

> MonoDevelop uses hard tabs. God, I have so much to teach it.

You can change the formatting settings for tabs and other syntax.

One of my firsts white-label projects was a match-3 (not unity, though).
Darn that was hard to debug with all the features they asked for.

Good luck!
Logged
internationalfish
Level 0
***


View Profile
« Reply #3 on: September 12, 2016, 06:41:04 AM »

Your gif's not working. It seems to be linked to localhost. Try hosting it online.

Blahaha, wow, localhost. Oops. I actually run a static site generator for the relevant blog, which rsyncs itself to deploy; apparently I thought it'd be a good idea to copy the image URL out of the wrong tab. Thank you for pointing that out. Cheesy

> MonoDevelop uses hard tabs. God, I have so much to teach it.

You can change the formatting settings for tabs and other syntax.

One of my firsts white-label projects was a match-3 (not unity, though).
Darn that was hard to debug with all the features they asked for.

Good luck!

Thanks! I actually didn't notice the tabs until I started putting code blocks in just now. I know the pain of irrational requirements; one of the draws of doing this as a hobby is not being beholden to clients.
Logged

internationalfish
Level 0
***


View Profile
« Reply #4 on: September 21, 2016, 12:03:22 AM »

Well, that was less than fun. Marginally productive, though.

I managed to get my remaining cubes to fill in the spaces left by my randomly-exploding cubes; I even managed to get them to do so from a rotating source direction, which is pretty cool to watch. Unfortunately, the part where new cubes happily hop in to fill the newly-lonely rows... well, that hasn't worked.

I'm not sure why, but my suspicion is there's something slightly different about instantiating game objects on the fly as opposed to creating them in Start/Active. I don't know what that might be or why, and it's entirely possible I'm just wrong, but at this point I'm not really sure what's going on.

In probably-unrelated news, I am starting to find Mono Develop less and less helpful, so that may get replaced in the near future.

There won't be another screen shot/animation on this until next week, as I'll be spending Screenshot Saturday getting married in Korea. This is what I'm currently blaming my typically-spotty game dev practice on.

Fortunately, 1GAM doesn't particularly care about releasing games on time as much as just releasing games, so I'm on board with that. Perhaps next month I'll be able to get this done early and get the next one out.

In the meantime, I suppose I'll go get some dinner and try to convince Unity to play nicely with me.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic