CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: Unicorn on July 10, 2016, 02:38:56 PM

Title: CC17: Unicorn
Post by: Unicorn on July 10, 2016, 02:38:56 PM
Following in the ways of the Ivoah, a crosspost.

Quote from: UnicornHey everyone! I've decided to enter this contest with an idea of my own :)

I just came up with a better idea for a game, without complex storylines and complicated mechanics. Without further ado, let me present Switch Operator!
---------------------------
Switch Operator
---------------------------
You take the place of a switch operator at a railroad tunnel. There are four lines, and each one has a gate for the trains to go through. Your job is to control the gates, as there are no sensors installed on the inside of this tunnel, so the gates only open automatically for incoming trains. You have to make sure that the trains don't run into a gate or some other obstacle. Only one gate can be open at a time, so you are constantly opening and closing them. Sometimes a gate will get stuck and you will have to make the train switch to an above or below track, and open the gate there. As the game progresses, the railroad upgrades their gate system so that multiple can be open at once, but they close automatically.
---------------------------
You will need to be fast with your fingers, as the gates are controlled by the numbers
  • , [1], [4], [7] (the western gates) and [(-)], [3], [5], [9] (the eastern gates). The switches are controlled by simultaneously pressing [.], [2], [5], or [8] for the corresponding track, and pressing the arrow key in the direction you want to switch it towards, North or South (or up and down)

    So I'm not sure how this question thing will work, but I can ask any manner of questions having to do with the C libraries and I will not be penalized?
Quote from: UnicornSo I've made progress! I have most of my sprites created and sorta working, so far.
EDIT: Turns out I misunderstood palettes a little :P

Anyways, heres a screenshot of the title screen. I need to fix up my erasing, but other than that, things are working out pretty good.

Quote from: Unicorn
Quote from: mr womp wompWow, very nice sprites and smooth moving, of course, you are going to want to get the cross sections of the track to be redrawn and maybe remove the white outline around  the train sprites, but it's looking good!
Thanks! I already have removed the white outlines, and the redrawing but is a little harder to fix, because the sprite is 7 pixels wide, and the train moves 1 at a time. I could make the train move 7, but I would have to slow it down, and slowing it down may make it look less smooth.
Quote from: UnicornIt is one train sprite, but I start drawing it at about X -190 so it looks as if it appears from the side of the screen. I do not use the clipping routine.

Anyways, I've made progress!

I've added highscores and actual loosing, as you can see in the screenshot. The pace of the game also increases as you progress.

Quote from: Unicorn
Quote from: MateoConLechugaA better option would be to double buffer and simply redraw the whole screen each time, and then swap buffers. This would be a lot easier than what you are trying to do currently :)
I'm not entirely sure how effective that is, it seems to be slow, so I'm sticking with my original method for now.

Besides that, though, I was wondering if anyone could make a short 2-4 page animation of this train switch to tracks above and below it?



The red line would be the path of the train.

Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on July 11, 2016, 05:53:57 AM
I like the sprites you use and this looks smooth. I'm glad you managed to get the clipping fixed so that the train won't appear instantly from the left.
Title: Re: CC17: Unicorn
Post by: MateoConLechuga on July 13, 2016, 04:55:43 AM
You say you don't use the clipping routine, but I'm about 99.99% certain you do :) Anywho, keep up the great work :D
Title: Re: CC17: Unicorn
Post by: Unicorn on July 13, 2016, 03:46:35 PM
I don't use the No_Clip routines....
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on July 14, 2016, 01:12:09 AM
How do you do the clipping then? Do you just use 8 bits mode and start drawing from outside the screen that way? Because I bet in 16 bits mode that could cause issues.
Title: Re: CC17: Unicorn
Post by: MateoConLechuga on July 14, 2016, 03:04:08 AM
Unicorn: By default, if it isnt specified to be _NoClip, it is clipped. This is to make it even easier for people who are just starting out. :) Anywho, keep up the great work :)
Title: Re: CC17: Unicorn
Post by: Unicorn on August 04, 2016, 11:18:10 PM
Yeah, I got confused :P


So its been a while since an update, abut here I am!

I'm got multiple trains moving at the same time! They start at a score of ten, but for screenshot purposes they started at a score of 1.

(the program isn't that fast on calc, I slowed it down. ;))

(https://usercontent.irccloud-cdn.com/file/yanctmUW/SwitchOp%20v1.5.gif)

So next I'm going to implement something of a story mode, with some images. Is there any way to have those without making huge sprites? Is there something like the xLIBC background command? There will also be a currency so you can "buy" added perks and help.
Also, if you let a train crash you have to pay for lost cargo, but you can bribe workers to say that it wasn't you to blame, causing pay for damages. (or you may be able to keep going, not sure yet)

What do you think?
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 05, 2016, 01:09:26 AM
Hm  a story mode would be interesting if you can find a way to make the images small. Maybe switch to 4 bits mode when in story mode and display the images scaled up to 200?

Also this screenshot looks very nice :)
Title: Re: CC17: Unicorn
Post by: Unicorn on August 05, 2016, 03:47:04 AM
Maybe... I could also just have a huge program that takes up half the archive
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 05, 2016, 03:57:22 AM
Erm, isn't the limit per file 64 KB? You will have to split the images into multiple appvars. If 95% of your game file size is just images for a cinematic then there should probably be an option to play without the big images, though, so people can play without installing the big files on their calc.
Title: Re: CC17: Unicorn
Post by: c4ooo on August 06, 2016, 12:10:18 PM
Quote from: Unicorn on August 04, 2016, 11:18:10 PM
So next I'm going to implement something of a story mode, with some images. Is there any way to have those without making huge sprites?
There is a text drawing command in the C libraries.
Also in this gif, since the grass and rails are just the same thing over and over, you don't have to store the whole image. If you aren't already, just use two for() loops to render all the grass and then two more for() loops to render the rails. :) I am talking about this:
(https://usercontent.irccloud-cdn.com/file/yanctmUW/SwitchOp%20v1.5.gif)
Title: Re: CC17: Unicorn
Post by: Unicorn on August 06, 2016, 07:17:41 PM
So the libraries do have a compression routine, I will use that, and I already am using loops to draw the grass and rails ;)

I'm trying to figure out how to use the buffers, so the raiils will actually end up looking much nicer.
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 07, 2016, 07:11:26 AM
Yeah you definitively don,t want to use one massive image to draw the entire screen. That is not size-efficient if you're doing that. If you use 8 bpp, the grass and rails should not be more than 32 bytes of sprite data, from what I see on your screenshot. Even the train, where the left end is repeated twice, can be made so that the repeated part re-uses sprites from the other half.

That said, I think what Unicorn was talking about was the cutscene/cinematic images for story mode. For example, if you want to draw a 128x60 picture that looks like an anime, then it sucks if you have to convert it into 8x8 sprite chunks, a tilemap then display each sprite one by one or via a tilemap. Being able to display the entire picture in one single command is much less tedious.
Title: Re: CC17: Unicorn
Post by: Unicorn on August 07, 2016, 07:15:09 AM
So it turns out that there is a compression routine, so I'll be using that, and only having a few pictures, the rest being drawn using rectangles and circles and lines.

The whole program takes up like 12 kb so far.
Title: Re: CC17: Unicorn
Post by: DarkestEx on August 07, 2016, 09:18:16 AM
Your game looks really nice :)
Keep it up!
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 07, 2016, 02:13:57 PM
Quote from: Unicorn on August 07, 2016, 07:15:09 AM
So it turns out that there is a compression routine, so I'll be using that, and only having a few pictures, the rest being drawn using rectangles and circles and lines.

The whole program takes up like 12 kb so far.
What about the terrain and train?
Title: Re: CC17: Unicorn
Post by: Unicorn on August 07, 2016, 06:14:17 PM
Quote from: DJ Omnimaga on August 07, 2016, 02:13:57 PM
Quote from: Unicorn on August 07, 2016, 07:15:09 AM
So it turns out that there is a compression routine, so I'll be using that, and only having a few pictures, the rest being drawn using rectangles and circles and lines.

The whole program takes up like 12 kb so far.
What about the terrain and train?
Yup, it includes that! The terrain is 16x16 (or it may be 8x8) and the train is kinda large, but the tracks are a small 7x20.

Thanks Darkest!
Title: Re: CC17: Unicorn
Post by: Unicorn on August 08, 2016, 04:17:45 AM
Bumpdate!

I've made it into three gamemodes, Campaign, Endless, and Bullet.
Campaign acts as a campaign, sort of like an rpg but not as complex. (I only have the base gameplay done)
Endless is endless, goes on forever until you lose, and it saves a highscore.
Bullet is endless but super fast and it doesn't have multiple trains at once. (Because that would be two hard) I'm going to add a separate highscore for this one.
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 08, 2016, 07:17:41 AM
I like those game modes. What kind of RPG elements will you include in campaing mode?

You could add an Endless-Bullet mode hybrid once Campaing has been beaten, which would be too hard but perhaps still possible using tool-assisted means? :trollface:
Title: Re: CC17: Unicorn
Post by: Unicorn on August 08, 2016, 08:15:30 PM
Quote from: DJ Omnimaga on August 08, 2016, 07:17:41 AM
I like those game modes. What kind of RPG elements will you include in campaign mode?

You could add an Endless-Bullet mode hybrid once Campaign has been beaten, which would be too hard but perhaps still possible using tool-assisted means? :trollface:
Thanks! In terms of RPG it wouldn't be like a fantasy one, you are really just role-playing as a switch operator at a railroad, with a bunch of options, like bribing people, as well as problems some problems. You will be able to upgrade things, like in an Rpg, but it really isn't one. :P

And yeah, maybe an endless bullet mode with multiple trains.. :trollface:

EDIT: Here's a screenshot!

(https://usercontent.irccloud-cdn.com/file/7v4am1Yz/SwitchOp%20v1.6.gif)
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 10, 2016, 06:59:15 PM
Someone should make a TAS of bullet mode when the game comes out publicly O.O
Title: Re: CC17: Unicorn
Post by: Unicorn on August 22, 2016, 05:16:53 AM
Haha maybe :P

So, here's an update!

- I've tweaked the menu screen around and added high-scores for both bullet and endless.
- I've created a story-line that displays when you enter campaign mode
- I've created an option to toggle the story (Pressing [Graph] )

(https://usercontent.irccloud-cdn.com/file/lMvqVEIh/SwitchOp%20v1.8.gif)
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 25, 2016, 03:32:14 AM
Nice :D. Adding a story was a nice touch.

On a side note I think the arrows should be more visible, such as maybe yellow. I hope you finish in time for the end of the contest. :)
Title: Re: CC17: Unicorn
Post by: Unicorn on August 27, 2016, 07:45:14 AM
Thanks! I don't think I'll be making the arrows more visible just because it would take to long the way everything is ser up currently.

Anyways, I've done things!

- Added more text to display balance and whether story is on
- Added a balance
- Added balance incrementing as you let trains through
- Added balance deduction when you crash
- Added messages for when you crash or go broke in campaign mode
- Fixed AppVar storing. (highscores and balance)

Screenshots tomorrow!
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 27, 2016, 04:28:45 PM
Cool to see progress! :) Can't wait to see the final result
Title: Re: CC17: Unicorn
Post by: Unicorn on August 28, 2016, 06:52:36 AM
Thanks!

So a question: Any idea why my setPerk() functions aren't displaying their strings?

setPerk function:

void setPerk(int perkName, const char perkStringName, int y) {
gfx_SetTextXY(15, y);
if (perkName == 0) {
gfx_SetTextFGColor(148);
gfx_PrintChar(perkStringName);
} else if (perkName == 1) {
gfx_SetTextFGColor(8);
gfx_PrintChar(perkStringName);
} else if (perkName == 2) {
gfx_SetTextFGColor(5);
gfx_PrintChar(perkStringName);
}
}

Calling of setPerk() :

gfx_FillScreen(gfx_black);
gfx_SetTextScale(2,2);
gfx_SetTextFGColor(8);
gfx_PrintStringXY("Upgrades", 40, 1);
gfx_SetTextScale(1,1);
// 0 means unavailabe
// 1 means able to buy
// 2 means bought
setPerk(slowDown1, "- Slower Trains 1", 50);
setPerk(slowDown2, "- Slower Trains 2", 60);
setPerk(moreMoney1, "- Better Paycheck 1", 70);
setPerk(moreMoney2, "- Better Paycheck 2", 80);
setPerk(moreMoney3, "- Better Paycheck 3", 90);
setPerk(track1Switch, "- Upgrade Track 1", 100);
setPerk(track2Switch, "- Upgrade Track 2", 110);
setPerk(track3Switch, "- Upgrade Track 3", 120);
setPerk(track4Switch, "- Upgrade Track 4", 130);
if (started == true) {
while (!kb_AnyKey()) {
}
}


Any ideas?
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 31, 2016, 06:22:07 AM
By the way, did you manage to get this solved and submit the entry in time?
Title: Re: CC17: Unicorn
Post by: Unicorn on August 31, 2016, 06:26:30 AM
Quote from: DJ Omnimaga on August 31, 2016, 06:22:07 AM
By the way, did you manage to get this solved and submit the entry in time?
Yup! I submitted, and because I have no school tomorrow, I can work more on it :D

Anyways, here's my posting/explanation of the game.

------------------------------------------------------------------------------------------------------------------------------------

This is a reaction based game. You must open the switches and allow trains to pass through before they crash into them.
There are four gamemodes, Campaign, Endless, and Bullet.
In campaign mode, whenever you open a switch for a train, you make money. If you let a train through without opening a switch, the train crashes and you lose money.
Endless mode just goes on forever, and you try to beat your highscore.
Bullet mode is exactly the same as endless, just without multiple trains and much faster.

Without further ado, here's a screenshot showing my making money, then buying upgrades, and then toggling things, and then playing other gamemodes. Pretty much every feature ;)

(https://usercontent.irccloud-cdn.com/file/amGAFWO6/SwitchOp%20v2.1.gif)

Also, if you want, check out the readme:

Quote
   _____           _  __         __       ____                             __                               __              __  __        _                         
  / ___/_      __ (_)/ /_ _____ / /_     / __ \ ____   ___   _____ ____ _ / /_ ____   _____                / /_   __  __   / / / /____   (_)_____ ____   _____ ____
  \__ \| | /| / // // __// ___// __ \   / / / // __ \ / _ \ / ___// __ `// __// __ \ / ___/    ______     / __ \ / / / /  / / / // __ \ / // ___// __ \ / ___// __ \
___/ /| |/ |/ // // /_ / /__ / / / /  / /_/ // /_/ //  __// /   / /_/ // /_ / /_/ // /       /_____/    / /_/ // /_/ /  / /_/ // / / // // /__ / /_/ // /   / / / /
/____/ |__/|__//_/ \__/ \___//_/ /_/   \____// .___/ \___//_/    \__,_/ \__/ \____//_/                  /_.___/ \__, /   \____//_/ /_//_/ \___/ \____//_/   /_/ /_/
                                            /_/                                                                /____/                                               

v2.1

About
------------------------------------------
This is a reaction based game. You must open the switches and allow trains to pass through before they crash into them.
There are four gamemodes, Campaign, Endless, and Bullet.
In campaign mode, whenever you open a switch for a train, you make money. If you let a train through without opening a switch, the train crashes and you lose money.
Endless mode just goes on forever, and you try to beat your highscore.
Bullet mode is exactly the same as endless, just without multiple trains and much faster.

Installation
------------------------------------------
Send SWITCHOP.8xp to your calculator using TI-Connect CE or TiLP.
Make sure you have the latest version of the C libraries - https://github.com/CE-Programming/libraries/releases/
Run it with Asm(prgmSWITCHOP on the homescreen, or install Cesium to run it - https://www.cemetech.net/programs/index.php?mode=file&id=1372

Gameplay
------------------------------------------    
   Menu:
      - You can press [Graph] to toggle the story when starting campaign, and use the Arrow Keys to Select a gamemode.
   Campaign Mode:
      - You have a balance that starts at $10
      - Whenever you open a switch for a train, you get anywhere from 1-10 dollars, depending on the upgrade you have.
      - If you let a train through, you lose anywhere from 15-7 dollars.
      - You use the money you make to upgrade your system and get pay raises. You can make trains go slower, make more money per train, have switches open for longer, and make switches automatic. Once you have automatic switches, you win the game.
      - You can reset on the upgrades screen with [Alpha]
      - If you end up with no money, you lose and have to start over.
   Endless Mode:
      - This is just the base game. If you let a train through with a switch open, you get a point, if you don't open a switch for a train, you lose.
      - If you get far enough, you will have to open switches for multiple trains.
      - Try to beat your highscore!
   Bullet Mode:
      - This mode is an extension of Endless, just 2-3 times faster, and without multiple trains.
   
How to play
------------------------------------------
   [Clear] exits every screen.
   [9] opens the top track
   [6] opens the second top track
   [3] opens the second bottom track
   [-] opens the bottom track
Title: Re: CC17: Unicorn
Post by: Dream of Omnimaga on August 31, 2016, 05:33:05 PM
Darn that game will be really fun to play I think. The screenshot is impressive. Why does the screen randomly flickers with red at the start of the screenshot, though?
Title: Re: CC17: Unicorn
Post by: Unicorn on August 31, 2016, 05:34:37 PM
Quote from: DJ Omnimaga on August 31, 2016, 05:33:05 PM
Darn that game will be really fun to play I think. The screenshot is impressive. Why does the screen randomly flickers with red at the start of the screenshot, though?
That is when I'm toggling the story ;)

And thanks!