Page 1 of 2

[Game] Tetris Windows 7+

Posted: 06 Sep 2017, 11:59
by maestrith
Controls:
-Left - Left
-Right - Right
-Up - Rotate Tetrimino
-Down -Drop Faster
-S - Drop to Bottom
-Q - Hold

Requires Windows 7+ and IE 11+
AutoHotkey_2017-09-06_12-56-22.png
(32.06 KiB) Downloaded 251 times
Source can be downloaded Here
0.000.3
Changed: Suggested by iPhilip
-ColorHLSToRGB: This is used to get colors that work well against a black background

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 13:03
by runie
Prettiest and most functional version of tetris written in AHK I think there is! Ghost piece is awesome.

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 13:06
by maestrith
RUNIE wrote:Prettiest and most functional version of tetris written in AHK I think there is! Ghost piece is awesome.
Thanks :)

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 14:04
by SKAN
Awesome! :bravo:

My score was like 4300 when my game ended and it simply began afresh... I couldn't see my final score.

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 14:08
by maestrith
SKAN wrote:Awesome! :bravo:

My score was like 4300 when my game ended and it simply began afresh... I couldn't see my final score.
I'll add in a msgbox or something for a score.

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 14:16
by maestrith
0.000.2
Added: Suggested by SKAN
-Final Score MsgBox

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 14:43
by jeeswg
This is really good. Yes the ghost piece is very nice (see where the piece is going to end up in advance), as is s to immediately place the piece.

I thought I might mention two nice old Windows games:

[This one is a relatively simple one, enemy planes, and your plane, fly around a 2D map, with blocks placed in many places. You can fire and they can fire.]
Alien Force : Robert Epps : Free Download & Streaming : Internet Archive
https://archive.org/details/win3_alienforce

[More complicated, but great game.]
Kye (video game) - Wikipedia
https://en.wikipedia.org/wiki/Kye_(video_game)

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 14:45
by SpeedMaster
Beautiful. :o
Thanks for sharing ! :bravo:

Suggestion:
Please can you insert this tag [Game] as a prefix in your title ?
this will make the search easier ;)

Re: Tetris Windows 7+

Posted: 06 Sep 2017, 15:15
by maestrith
SpeedMaster wrote:Beautiful. :o
Thanks for sharing ! :bravo:

Suggestion:
Please can you insert this tag [Game] as a prefix in your title ?
this will make the search easier ;)
:) Thanks and No Problem :)

Re: [Game] Tetris Windows 7+

Posted: 10 Sep 2017, 20:18
by kczx3
12,900
Lines: 117

Re: [Game] Tetris Windows 7+

Posted: 10 Sep 2017, 20:22
by maestrith
kczx3 wrote:12,900
Lines: 117
:thumbup:

Re: [Game] Tetris Windows 7+

Posted: 27 May 2020, 19:16
by joefiesta
interesting. but, many of the pieces are near impossible to see. they are too dark against the black background.

Re: [Game] Tetris Windows 7+

Posted: 27 May 2020, 19:20
by maestrith
joefiesta wrote:
27 May 2020, 19:16
interesting. but, many of the pieces are near impossible to see. they are too dark against the black background.
Yea, I just did random colors...

Re: [Game] Tetris Windows 7+

Posted: 28 May 2020, 11:49
by iPhilip
maestrith wrote:
27 May 2020, 19:20
joefiesta wrote:
27 May 2020, 19:16
interesting. but, many of the pieces are near impossible to see. they are too dark against the black background.
Yea, I just did random colors...
Hi maestrith,

You might want to experiment with this approach to getting colors that work against a black background. I have found it useful in my code:

Code: Select all

ColorARGB := "0xFF" ColorHLSToRGB(i > 240 ? mod(i, 240) : i, 120, 240)  ; i is an integer, e.g. A_Index

; Reference: https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-colorhlstorgb - ColorHLSToRGB function

ColorHLSToRGB(Hue, Luminance, Saturation) {
   BGR := DllCall("shlwapi.dll\ColorHLSToRGB", "UShort", Hue, "UShort", Luminance, "UShort", Saturation, "UInt")
   Return Format("{:06X}", ((BGR & 0xFF) << 16) | (BGR & 0xFF00) | ((BGR >> 16) & 0xFF))
}
Cheers,

- iPhilip

Re: [Game] Tetris Windows 7+

Posted: 30 May 2020, 14:55
by joefiesta
@iPhilip - what does your code have to do with Tetris? And, what does it do? The variables you define aren't used in the Tetris script.

Re: [Game] Tetris Windows 7+

Posted: 30 May 2020, 15:19
by iPhilip
joefiesta wrote:
30 May 2020, 14:55
@iPhilip - what does your code have to do with Tetris? And, what does it do? The variables you define aren't used in the Tetris script.
Hi @joefiesta,

Thank you for your questions. I imagine you are confused by my message. Actually I was responding to a thread initiated by your comment
joefiesta wrote:
27 May 2020, 19:16
... but, many of the pieces are near impossible to see. they are too dark against the black background.
by offering a way to get colors that are more visible against a black background. I left it to @maestrith to decide whether to integrate the code into the Tetris script. Here is some code you can run to see the effect:

Code: Select all

#NoEnv

Gui, Color, Black
Gui, Add, Progress, x100 y100 w100 h100 cBlue BackgroundBlack vMyProgress, 100
Gui, Show, w300 h300, Colors

Loop
{
   Random, Index, 0, 240
   Color := ColorHLSToRGB(Index, 120, 240)
   ; Random, Color, 222222, 999999  ; Uncomment to see current color scheme in Tetris
   GuiControl, % "+c" Color, MyProgress
   Sleep 1000
}

; Reference: https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-colorhlstorgb - ColorHLSToRGB function

ColorHLSToRGB(Hue, Luminance, Saturation) {
   BGR := DllCall("shlwapi.dll\ColorHLSToRGB", "UShort", Hue, "UShort", Luminance, "UShort", Saturation, "UInt")
   Return Format("{:06X}", ((BGR & 0xFF) << 16) | (BGR & 0xFF00) | ((BGR >> 16) & 0xFF))
}

GuiClose:
GuiEscape:
   ExitApp
Again, it was just a suggestion to help address the problem you identified. If it's not useful, feel free to disregard.

Cheers,

- iPhilip

Re: [Game] Tetris Windows 7+

Posted: 01 Jun 2020, 07:55
by joefiesta
@iPhilip - Thanks. I didn't mean to be disrespectful. I thought you meant I could drop your code into Tetris. I'm sure I can figure out what you're doing and can figure out revising tetris on my own even though it is very complicated, what with so many objects and such I know little about. But, considering this forum entry got almost no interest, I suspect nobody even uses the script. So, I doubt the author has much concern at this point. He was probably just working on his game writing skills.

Re: [Game] Tetris Windows 7+

Posted: 01 Jun 2020, 07:58
by maestrith
joefiesta wrote:
01 Jun 2020, 07:55
@iPhilip - Thanks. I didn't mean to be disrespectful. I thought you meant I could drop your code into Tetris. I'm sure I can figure out what you're doing and can figure out revising tetris on my own even though it is very complicated, what with so many objects and such I know little about. But, considering this forum entry got almost no interest, I suspect nobody even uses the script. So, I doubt the author has much concern at this point. He was probably just working on his game writing skills.
I added it to the main script already.

Re: [Game] Tetris Windows 7+

Posted: 01 Jun 2020, 08:27
by joefiesta
@maestrith - Thanks. A humungous improvement. Rather primary colors, but, they are perfect considering the simplicity of the game.

If I dare say, I would like to suggest some other changes. It's been decades since I played tetris on an ancient nintendo box. I don't remember the ghost square, but I like it, even though it makes playing easier.

1. The ghost piece would be nicer if it were more visible (solidly colored), say a somewhat dark shade of gray.
2. Levels would be nice. As one clears oh I don't know perhaps 25 lines, the speed of the pieces falling could increase a little, and the scoring could increase a little. I vaguing remember, too, that with Tetris as it got more difficult the shapes selected were less random--that is to say duplicate shapes tended to occur in sequence more often (which adds to the difficulty). But, I could be wrong about such a memory.
3. I would like the BLUE line surrounding the playing field to be brighter (more visible).
4. The help instructions on the side are rather difficult to read also. They could be a lighter shade of pink.

But, my compliments on a beautiful piece of coding. I guess it's time I learned about the advanced object (terminology??) techiniques you employ. But, what do you want from a retired mainframe programmer.

thanks again for the color fix.

Re: [Game] Tetris Windows 7+

Posted: 03 Jun 2020, 11:46
by iPhilip
joefiesta wrote:
01 Jun 2020, 07:55
@iPhilip - Thanks. I didn't mean to be disrespectful. I thought you meant I could drop your code into Tetris. I'm sure I can figure out what you're doing and can figure out revising tetris on my own even though it is very complicated, what with so many objects and such I know little about. But, considering this forum entry got almost no interest, I suspect nobody even uses the script. So, I doubt the author has much concern at this point. He was probably just working on his game writing skills.
Hi @joefiesta,

Thank you for your note. I appreciate you reaching out to me. I totally empathize with you on the challenge of modifying other people's code. I mean, it's hard enough going back to my own code and figuring out why I did what I did - even with documentation and comments! :lol:

I am glad that @maestrith was able to integrate the function into the game. As you noted above, it's a significant improvement. :) When I played the new game, I noticed that the randomization of the colors was adding a degree of difficulty for me as my mind was trying to associate colors with shapes in order to anticipate the appropriate rotation or move. Who knew that color could add a degree of difficulty to a game! ;)

Cheers,

- iPhilip