Author Topic: SCI Tetris  (Read 1560 times)

0 Members and 1 Guest are viewing this topic.

Offline cosmicr

SCI Tetris
« on: September 19, 2020, 10:34:59 PM »
I've been slowly learning SCI programming, working on my game. As always my game is huge in scope and I needed a diversion.

I wanted to try to familiarise myself with a few lesser used functions of SCI and learn a bit more in the process, on a smaller game.

So today I present: SCI Tetris!



No don't check your calendar, this isn't an April Fools joke...
It's all coded in one room. I've included the source for anyone who wants to take a look (warning it's quite messy). Anyone new to SCI programming might learn a few things.

How it works and my methodology:
  • I keep an array of the board in a 20x10 array. SCI doesn't support 2d arrays, so it's basically a 200 element array.
    The blocks are programatically generated from one View (with 6 loops) and move down the board. A popular implementation of a Tetris game.
    When the blocks hit the bottom they become part of the board and I used the AddToPic function. One of the issues I had to overcome was the addToPic library function doesn't work the way I wanted it to so I used the Kernel function instead.
  • Once I had the main game working, I added boundary and lines cleared detection. I used the template gScore and gMaxScore for the scoring. I also used the death handler but modified it to display a random Russian "Superstition" just for fun (and to abuse the text resource feature). I copied all the quotes from Wikipedia into a text file, then using a hex editor I replaced all the CRLF's with 0's and imported the text patch into my game.
  • The game gets progressively faster as you level up. Rosella is there to give you a sense of urgency.
  • I had a bit of trouble with keys. I'm not sure if SCI0 allows a key-held event. So for that reason you can't hold a key down you have to "tap" the key controls.  I didn't spend a lot of time on controls so it might be possible to improve.
  • High scoring is saved to a local file in the game folder so that next time you play it's still there.  The big font is just a "Russian" style Cyrillic-looking font that I found online.
  • Save and restore sort of don't work, but it wouldn't take much to make it work. But why you'd want that is beyond me hahaha.
  • There's also some midi music in there too.
  • I should also add I used Kawa's version of SCI Companion, but I don't think it makes any difference.
  • If anyone's wondering this is the result of about 12 hours coding/design/learning (about 2 days).

So anyway I've attached the game files to this post, take a look, let me know what you think, and any questions you might have!

Now back to my main game...
« Last Edit: September 19, 2020, 10:43:02 PM by cosmicr »



Offline Kawa

Re: SCI Tetris
« Reply #1 on: September 20, 2020, 06:36:01 AM »
Well, that's awesome, you're awesome.

Offline Doan Sephim

Re: SCI Tetris
« Reply #2 on: September 20, 2020, 09:19:58 AM »
Very cool! I look forward to giving this a go!

Offline OmerMor

Re: SCI Tetris
« Reply #3 on: September 20, 2020, 02:20:57 PM »
Cool!

Offline EricOakford

Re: SCI Tetris
« Reply #4 on: September 22, 2020, 10:52:01 AM »
I've played through this a bit, and greatly optimized the code. Here are some of the changes made:

Quote
The system scripts and globals have been replaced with the original Sierra ones.

Unnecessary LSL3 remnants have been removed.

The high-score file is now managed entirely by a distinct File object and its methods. This is much simpler than using the kernel functions.

The menu bar has been greatly simplified. Save and Restore aren't needed for this kind of game.

You can now move blocks with the arrow keys as well as WASD.

My SCI templates
SCI0 SCI0.1 SCI1.0 SCI1.1
SCI2.1 planned

Offline cosmicr

Re: SCI Tetris
« Reply #5 on: September 22, 2020, 05:40:04 PM »
Awesome. Very nice.  I thought about removing all the redundant scripts but thought best to leave it alone. The 1.1 version is what it would have been if I wasn't sick of working on it hahaha. Are these new scripts from your templates? Do you have a full list somewhere of the changes you've made on those?

I originally left the save/restore in because I thought it was funny and was also a reminder that you're playing tetris on a Sierra game engine.

What does the (`) Grave accent (backwards apostrophe?) do on the wasd control section? Convert the literal to a number? Is that documented somewhere?

Interesting it feels a lot more responsive now. Could all the overhead make such a difference?

Offline OmerMor

Re: SCI Tetris
« Reply #6 on: September 23, 2020, 04:49:21 AM »
What does the (`) Grave accent (backwards apostrophe?) do on the wasd control section? Convert the literal to a number? Is that documented somewhere?

` denotes the following character as the key for the menu.

See here.

Offline cosmicr

Re: SCI Tetris
« Reply #7 on: September 23, 2020, 05:21:03 AM »
Hmm weird
I thought that only applied to menu definitions.

Offline OmerMor

Re: SCI Tetris
« Reply #8 on: September 23, 2020, 05:41:36 AM »
Hmm weird
I thought that only applied to menu definitions.

Oh, sorry - I think what you're talking about is the single character notation:

Code: [Select]
Characters are single ASCII characters, and are denoted by preceding the
character with the reverse single quote ("tick") character:

     `A   represents uppercase A and
     `?   represents the question mark

Several character sequences represent special key combinations:

     `^a  represents ctrl-A
     `@b  represents alt-B
     `#4  represents the F4 key

See here.

Offline Kawa

Re: SCI Tetris
« Reply #9 on: September 23, 2020, 07:14:06 AM »
I tried to add a Bag of Seven randomizer but I can't seem to get it down.

Offline gumby

Re: SCI Tetris
« Reply #10 on: September 25, 2020, 08:34:07 PM »
Game is now downloadable from the games page:  http://sciprogramming.com/fangames.php?action=review&id=208
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline ZvikaZ

Re: SCI Tetris
« Reply #11 on: October 04, 2020, 05:55:56 AM »
Maybe it's better to link the game page, the improved version of EricOakford?


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.117 seconds with 24 queries.