Author Topic: A Tetris clone in Oxygenbasic  (Read 1330 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Hero Member
  • *****
  • Posts: 973
A Tetris clone in Oxygenbasic
« on: June 09, 2019, 03:03:17 AM »
Hello,

there is a lot of code available which deal with the game of Tetris. So I adapted the logic of one for the existing solutions to Oxygenbasic. The app is intended to play in a console window, I added sound and levels to the existing code and a better graphical display. The final result differs in some way from the original program written in C.

With my system the app can be run with Oxygen of Feb/2019 and the new version of June/2019. The game can be played without sound, but using sound is much more fun.

Attached is AsciTetrix.o2bas and some midi files which I found at bitmidi.com. Other midi files could also be used.
About the levels: I suppose it is difficult to reach level 12.

Roland

Code: [Select]
'Tetris clone in a console window
'logic adapted from:
'https://github.com/curaai00/Tetris


$ filename "AsciTerix.exe"
'uses rtl32
'uses rtl64

uses corewin
uses console

indexbase 0

....


Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4330
    • Oxygen Basic
Re: A Tetris clone in Oxygenbasic
« Reply #1 on: June 09, 2019, 03:48:40 PM »
Many Thanks, Roland,  for porting this classical game into o2.

I would like to include it along with TowerOfHanoi and other console programs in projectsB\Console.

It will also make a very good candidate for an Opengl version one day :)

Arnold

  • Hero Member
  • *****
  • Posts: 973
Re: A Tetris clone in Oxygenbasic
« Reply #2 on: June 10, 2019, 03:39:07 AM »
Hi Charles,

as for me, there are really no problems. Being autodidactic, with Oxygenbasic and your help I learned more about programming than was possible for me with other languages. And because O2 is designed so flexible, it is still possible to add new ideas and features, as suggested by Mike, Josť and Brian.

I took this special approach for the puzzle because it uses a structure as argument for functions/subs and allocates and frees memory with getmemory and freememory. Using the macro get_board and the function get_shapes it is possible to fetch/store values from/to a two- and four-dimensional array using indexbase 0. (get_shapes as a macro did not work, perhaps I did something wrong). Moreover I wanted to learn more about the mciSendString and mciSendCommand functions which seem to offer a lot of application possibilities. Another goal was to apply the GetAsynckeyState function for the arrow keys, but the use for this function in a console window seems to be limited. The same goes for applying some minimal graphics in a console window, this really seems not to be possible any more.

But overall this little project was very educational for me. And therefore Oxygen is so inspirational for me. With the new update 0.2 permitting unicode extensions you opened the door to another new interesting applicability.

Roland

Brian Alvarez

  • Hero Member
  • *****
  • Posts: 588
    • PluriBASIC
Re: A Tetris clone in Oxygenbasic
« Reply #3 on: July 23, 2019, 08:09:40 PM »
  Arnold, what OS are you using? My Win7 is acting weird and i hear no sound... :(

Good game though! :)

Arnold

  • Hero Member
  • *****
  • Posts: 973
Re: A Tetris clone in Oxygenbasic
« Reply #4 on: July 23, 2019, 11:13:52 PM »
Hi Brian,

I use Windows 10. The mid files must be located in the same folder as the app. Did you check your volume mixer? If I open the mixer separately, I can see if the speakers are mute and I can also see the app running. I know that there is a volume mixer in Win 7 too, but I do not recall if it works similar like the mixer in Win 10.

Brian Alvarez

  • Hero Member
  • *****
  • Posts: 588
    • PluriBASIC
Re: A Tetris clone in Oxygenbasic
« Reply #5 on: July 24, 2019, 12:08:29 PM »
 Hello Arnold, yes, i checked it ut the issue ended up being something else, not related to the game. :)

 You gave me the idea... i will try to create Dr. Mario for oxygen basic. :) :) :)
I loved that game when i was a kid.