Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Sorunome on October 23, 2011, 02:41:05 pm

Title: Grammer Tetris
Post by: Sorunome on October 23, 2011, 02:41:05 pm
Hi, I have started some days ago programming Tetris in grammer! Some of you may have noticed me talking about it on chat. Well, for those who don't: I have already pretty much done, I think I'll have the beta up soon!
What I have already done:
 - all blocks, you can rotate them
 - checks that you can't go to far left/right
 - checks that you cant go through other blocks
 - checks whether the block hits the bottom or a other block
 - the possibility for fast down (pressing down-button)
 - automatic go down

Things I have to add for the beta:
 - check whether a line is complete
 - make that line go away
 - check whether you lost
 - put in that it is random what figure appears (easy, just one line of code! :D)
 - take out the possibility to change the figure by pressing 2ND :D :D :D

Things I then STILL have to do for the full version:
 - score
 - make it go down faster after some time
 - menu
 - high-score list
 - display the next block
( - some other cool features!)

Sorry, I don't have any screenies yet. I don't know if I will even make any before the betta. Please tell what you think about it! :)
Title: Re: Grammer Tetris
Post by: Yeong on October 23, 2011, 03:24:06 pm
good luck! XD
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 23, 2011, 03:47:40 pm
So you have a way to make sure the block doesn't go through another block? Then you can probably use a series of pxl-Test( in a for loop to test if a line is complete. If the shape was 2 blocks tall, you only need to test those two rows.

Use the same idea for checking if you lose :)

As for shifting blocks down, I am not sure how that will work :/ I know I could whip up some code in Grammer, but it would be a little complicated and use several buffers.

EDIT: Okay, here is the complicated piece code I was talking about XD It took some thought, but I figured it out :)
Code: [Select]
Send(768,"VGBuf→K
37696→J
Lbl "SD→I

<<code>>

.SD
Disp K
ClrDraw
Line(X,Y,H-4,W,1
Fill(10,J
Fill(13,J
Tangent(4,1
Fill(13,J
Disp J
Line(X,Y,H,W,0
Fill(9,K
End
The shifting code is at .SD
The inputs to that subroutine are:

X and Y are the upper left coordinates of the place to begin shifting at
H and W are the height and width of the region to shift down
K points to a 768-byte buffer
J points to the main buffer (usually the graph buffer)
I hope that helps!
Title: Re: Grammer Tetris
Post by: Stefan Bauwens on October 24, 2011, 05:12:46 am
Good luck with this. :D
Title: Re: Grammer Tetris
Post by: Sorunome on October 24, 2011, 10:42:57 am
So you have a way to make sure the block doesn't go through another block? Then you can probably use a series of pxl-Test( in a for loop to test if a line is complete. If the shape was 2 blocks tall, you only need to test those two rows.

Use the same idea for checking if you lose :)

As for shifting blocks down, I am not sure how that will work Undecided I know I could whip up some code in Grammer, but it would be a little complicated and use several buffers.
I was already going to make the check weather a line is complete with pixel checks. :P
And If you lose I wanted to check the y-variable, if it is to small you lose.
And to the shifting: I draw all figures twice: once it leaves the loop where it waits for a keypress/shifting down it draws the figure in white pixels, I change the position of the figure and then I draw it in black ones! xD
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 24, 2011, 05:09:03 pm
Oh, I meant shifting the whole block so when a row gets deleted, the ones above can be shifted down :)
Title: Re: Grammer Tetris
Post by: Anima on October 24, 2011, 06:16:46 pm
Good luck! :)
Title: Re: Grammer Tetris
Post by: Sorunome on October 25, 2011, 06:54:47 am
Oh, I meant shifting the whole block so when a row gets deleted, the ones above can be shifted down :)
I alswell wanted to do that with ixel test. :)
Title: Re: Grammer Tetris
Post by: Sorunome on October 26, 2011, 09:01:04 am
I don't know why, but it throughs an error when it shall shift everything down if a line is complete.....
Well, this is the responsible code:
Code: [Select]
:For(O,1,26
:0→H
:For(A,1,10
:H +pxl-Test(65535+O*4,1+4*A)
:→H
:End
:If H=10
:Then
:O-1→O
:For(P,0,O)
:For(Q,1,10)
:O-P→R
:pxl-Test(4*R,4*Q)→K
:If K=1
:Then
:Line(4*Q,4*R,4,4,0
:Line(4*Q,4*1+R,4,4,1
:End
:If K=0
:Line(4*Q,4*1+R,4,4,0
:DispGraph
:End
:End
:
:End
Please help me! D:
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 26, 2011, 09:15:05 am
Okay, so you asked on IRC about how to use the code I gave, but I will post here anyway...
With mine, you will need 2 buffers J and K. Just use 37696→J for the graph buffer and create a tempprog of 768 bytes for the other. So somewhere at the beginning of your code:
Code: [Select]
37696→J
Send(768,"VTeMP→K
...And yes, that is a lowercase e >.>
Title: Re: Grammer Tetris
Post by: Sorunome on October 26, 2011, 10:20:04 am
Ok, cool, thanks. I think I'll have beta up soon!
All I need to do now is a check whether you die! :)
Title: Re: Grammer Tetris
Post by: Sorunome on October 26, 2011, 11:41:55 am
Ok, I have finally finished the beta of this! (Some of you may think this isn't allowed due to double posting rules, but I checked them and you may double post in the next hour when you have big project updates)
Well, the controls are simple, up is rotate block, and the other arrow keys are quite obvious! :P
Clear is exit.
If you lose the game just simply exits.
Be sure to check out the screenshot!
Title: Re: Grammer Tetris
Post by: Yeong on October 26, 2011, 11:43:59 am
Just tried. Nice!
It gives me syntax error if I die :P
Title: Re: Grammer Tetris
Post by: Stefan Bauwens on October 26, 2011, 11:55:20 am
Looks very nice! :D
Title: Re: Grammer Tetris
Post by: Sorunome on October 26, 2011, 11:56:43 am
Thanks both of you!
Yeong: I don't know why it throughs a syntax error, to me it doesn't... :S
Title: Re: Grammer Tetris
Post by: JustCause on October 26, 2011, 01:37:41 pm
Looks impressive! I'll try this out when I can.
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 26, 2011, 01:40:13 pm
Wow, I was just going to look up some math stuff when I got distracted by Omnimaga. Great job Sorunome! I plan to download this as soon as I get back home!
Title: Re: Grammer Tetris
Post by: Sorunome on October 26, 2011, 01:41:41 pm
Cool! Thanks both of you!
Xeda: If you want to optimize the code, feel free to do so, but I think you'll have to talk with yeong, 'cause he is optimizing the code atm! :P
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 26, 2011, 01:43:34 pm
Awwwww, I wish these computers had ti-connect D: This is too cool, I didn't know how great it would turn out!
Title: Re: Grammer Tetris
Post by: Yeong on October 26, 2011, 02:58:00 pm
Cool! Thanks both of you!
Xeda: If you want to optimize the code, feel free to do so, but I think you'll have to talk with yeong, 'cause he is optimizing the code atm! :P
and cleared around like 70-80 bytes of codes :D (so far)
Title: Re: Grammer Tetris
Post by: Sorunome on October 26, 2011, 03:00:29 pm
Cool! Thanks a lot! :)
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 26, 2011, 03:30:44 pm
Hehe, I am sure I can clear out a few hundred in one fell swoop Fwahahaha :D
It helps that I know most of the super optimisations >.>

EDIT: I got it down to 3800 bytes, but it seems to mess up the screen after starting, so I will need to go through and fix stuff D:
EDIT2: It was just a mislabled label :D It now works, but it doesn't detect a filled line or when you are dead D: Now I have to see where I broke that D:
Title: Re: Grammer Tetris
Post by: Yeong on October 26, 2011, 04:30:53 pm
Hehe, I am sure I can clear out a few hundred in one fell swoop Fwahahaha :D
It helps that I know most of the super optimisations >.>

EDIT: I got it down to 3800 bytes, but it seems to mess up the screen after starting, so I will need to go through and fix stuff D:
EDIT2: It was just a mislabled label :D It now works, but it doesn't detect a filled line or when you are dead D: Now I have to see where I broke that D:
<_<
lol
Title: Re: Grammer Tetris
Post by: Yeong on October 27, 2011, 05:57:00 pm
bug report:
Title: Re: Grammer Tetris
Post by: Builderboy on October 27, 2011, 06:02:47 pm
Btw what is the routine you are using for line clearing?  It looks a tad bit slow and maybe i could provide a quick solution :D
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 27, 2011, 07:00:02 pm
Um, the way he had it was one I designed as a workaround... It had to use another buffer doing some fancy masking. The next version should have a new method, though, that is a Grammer rectangle routine that shifts a section of the screen.

I think the speed issue is all of the If statements and pixel tests, though x.x

@yeong: Which version is that? Is that the 5000 byte version?
Title: Re: Grammer Tetris
Post by: Yeong on October 27, 2011, 07:46:07 pm
yes.
Title: Re: Grammer Tetris
Post by: TIfanx1999 on October 27, 2011, 08:14:03 pm
Looks really nice :D, minus the bug.  x.x
Title: Re: Grammer Tetris
Post by: annoyingcalc on October 27, 2011, 08:21:20 pm
cant wait untill it gets released
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 27, 2011, 08:22:12 pm
Well you can download the beta...
Title: Re: Grammer Tetris
Post by: annoyingcalc on October 27, 2011, 08:44:27 pm
I know it is so awesome
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 27, 2011, 08:45:08 pm
I kind of want to see just how fast and optimised I can make it... >.>
Title: Re: Grammer Tetris
Post by: JustCause on October 27, 2011, 08:53:14 pm
I kind of want to see just how fast and optimised I can make it... >.>
And then suddenly Xeda codes Tetris in eight bytes.
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 27, 2011, 08:55:09 pm
7, actually >.>
(not really!)
Title: Re: Grammer Tetris
Post by: mrmprog on October 27, 2011, 08:55:23 pm
Well...
Code: [Select]
:Tetris()
Syntax: no args, starts a game of tetris.
This should definitely be a command.
Title: Re: Grammer Tetris
Post by: Xeda112358 on October 27, 2011, 08:56:07 pm
Actually, I could make that a command. Seriously. I was thinking of including subprograms directly in the App data.
Title: Re: Grammer Tetris
Post by: Yeong on October 28, 2011, 07:36:07 am
Code: [Select]
:ARUN()
:ARUN.ACHIEVEMENT(unlock)
Title: Re: Grammer Tetris
Post by: Sorunome on October 28, 2011, 03:31:50 pm
I feel like I missed something.... so many new posts! O.o Well:
@annoyingcalc: thanks!
@yeong: I thought, that I had removed all these bugs...... I don't know why, I'll check the code again.

I'm also currently working on the score. :)


EDIT: Fixed that bug! :)
Title: Re: Grammer Tetris
Post by: Xeda112358 on November 11, 2011, 08:51:43 am
Awesome! Cool :D Do you have an update posted? I am trying to think of what commands I can add to speed up Tetris...

EDIT: I was also wondering if I could use the Tetris screenie to show off what Grammer can do? (like when I update on TICalc and whatnot)
Title: Re: Grammer Tetris
Post by: Nick on November 11, 2011, 09:48:19 am
i don't know if i can help, but it might be better/faster not to use a pixel test to check if the block has to stop. I use a table that represents the field, and every scuare block is one element in the table, so you should have a table of 20x10 i think (20 rows, 10 cols)

you just have to check if the tablevalue is 0 or 1 and if 1, stop moving..
Title: Re: Grammer Tetris
Post by: Xeda112358 on November 11, 2011, 10:04:55 am
I am not sure that would speed things up too  much just because of how Grammer works. Grammer treats pixel testing as reading from an array as it is, but that could still be useful... Thanks!
Title: Re: Grammer Tetris
Post by: Nick on November 11, 2011, 11:05:34 am
oh sorry, well i don't know grammer xs but i'll thought, why not, maybe it will helps. but i wish you good luck with it, it looks nice and fluent :)
Title: Re: Grammer Tetris
Post by: Sorunome on November 11, 2011, 11:21:47 am
Ok, here are some updates: I added now a score, the figures now fall down from all the top (they begin outside the screen) and it also gets faster after some time.
@Xeda: yeah, just use it, the screenie! :)
Title: Re: Grammer Tetris
Post by: Xeda112358 on November 11, 2011, 11:30:57 am
:D Thanks! And hooray for updates :D
Title: Re: Grammer Tetris
Post by: contra-sh on November 20, 2011, 12:45:24 pm
Hey good luck for the zcontest :)

I'm a tetris fan, nice game :)
Title: Re: Grammer Tetris
Post by: Sorunome on November 20, 2011, 12:47:53 pm
Thanks! I'll update ass soon as possible, Xeda is currently optimizing the code! :)
Title: Re: Grammer Tetris
Post by: Xeda112358 on November 20, 2011, 01:08:58 pm
I only could optimise a little bit, so far, so good coding! And I also noticed that this is about as fast and as smooth as a Gameboy game I played one O.O
Title: Re: Grammer Tetris
Post by: Sorunome on November 20, 2011, 01:19:33 pm
 :w00t: Cool! Thanks! :)
Title: Re: Grammer Tetris
Post by: Sorunome on November 22, 2011, 01:16:18 pm
 :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:

I finished The final Version 1.0!!!!!!!!!!!!!!!!!!!
Well, here it is:
Download! (http://www.omnimaga.org/index.php?action=downloads;sa=view;down=747)

(http://img.removedfromgame.com/imgs/tetris beta 2.gif)
Title: Re: Grammer Tetris
Post by: aeTIos on November 22, 2011, 01:17:30 pm
Ooh, great job!
Title: Re: Grammer Tetris
Post by: Sorunome on November 22, 2011, 01:18:28 pm
Thanks a lot! Tell if you have any idea how to make it more awesome! :)
Title: Re: Grammer Tetris
Post by: Stefan Bauwens on November 22, 2011, 01:21:58 pm
:w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:

I finished The final Version 1.0!!!!!!!!!!!!!!!!!!!
Well, here it is:
Download! (http://www.omnimaga.org/index.php?action=downloads;sa=view;down=747)

(http://img.removedfromgame.com/imgs/tetris beta 2.gif)
Looks wonderfull. :D Just the score looks a little strange to me IMHO.
Title: Re: Grammer Tetris
Post by: Sorunome on November 22, 2011, 01:24:43 pm
Well, evrytime you press down you get a score of +1
Title: Re: Grammer Tetris
Post by: Xeda112358 on November 22, 2011, 01:40:59 pm
Awesome job Sorunome! I like that the options are saved, too! And the menu selection thingy is lovely :3 +1 :D
Title: Re: Grammer Tetris
Post by: Sorunome on November 22, 2011, 02:12:48 pm
Cool, thanks!
One of the best things I'm at at programming is menus, even that options are saved :) (That main menu was made in like three minuets ^^)
Title: Re: Grammer Tetris
Post by: Stefan Bauwens on November 22, 2011, 04:01:39 pm
Yeah, the menu is quite cool. :D Also I guess that highscore thing is Ok.
Title: Re: Grammer Tetris
Post by: Sorunome on November 23, 2011, 07:45:52 am
Thanks! Have you got any idea how to make it even more awesome?
Title: Re: Grammer Tetris
Post by: Iambian on November 23, 2011, 08:04:13 am
Looking quite nice!
Thanks! Have you got any idea how to make it even more awesome?
I would suggest a way to make a block instantly fall down without having to spend time watching it fly, even if you're holding down.
Title: Re: Grammer Tetris
Post by: Stefan Bauwens on November 23, 2011, 08:53:03 am
Yeah, thats true. Also if you're bored you could make an insane death scene. :P lol.
Title: Re: Grammer Tetris
Post by: Sorunome on November 23, 2011, 11:15:07 am
D: That would be complicated, and I don't know if it would be much faster....but I'll try! :)
Title: Re: Grammer Tetris
Post by: DJ Omnimaga on December 29, 2011, 02:46:44 am
:w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:  :w00t:

I finished The final Version 1.0!!!!!!!!!!!!!!!!!!!
Well, here it is:
Download! (http://www.omnimaga.org/index.php?action=downloads;sa=view;down=747)

(http://img.removedfromgame.com/imgs/tetris beta 2.gif)
Level 3 seems hard O.O, blocks falls faster than the last levels in the NES Tetris O.O

Nice, though.
Title: Re: Grammer Tetris
Post by: Sorunome on December 29, 2011, 03:57:43 am
It is just so fast because xeda pressed down during making of the screenie :P
And thanks! :)
Title: Re: Grammer Tetris
Post by: Xeda112358 on December 29, 2011, 09:03:45 am
Oh, well I will say that level 8 with the new version of Grammer is quite fast x.x I wonder if you might need to recalibrate the delays .___.

The new version did manage to speed up Tetris a bit...
Title: Re: Grammer Tetris
Post by: Sorunome on December 29, 2011, 09:31:38 am
O.o that is fast.../me really has to recalibrate, but i think i'll first of all work more on mino. :)
Title: Re: Grammer Tetris
Post by: DJ Omnimaga on December 31, 2011, 03:17:23 pm
Ah I see now, I thought this was because it was like some sort of extreme difficulty Tetris. :P