LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tetris in Labview

I've written a Tetris game in LabView as a tutorial for some co-workers to show how to write GUI applications using a task queue, event structures and a state machine to do the heavy lifting.  I would be glad to share it here if anybody is interested. 
 
Sheldon
Technical geek, engineer, research scientist, biodegradable...
Message 1 of 58
(18,220 Views)
Upload it

as the quote goes  'learn what you can, share what you know'
chow xseadog
Message 2 of 58
(18,191 Views)
Hi there !
 
Tetris  in LabVIEW that  sounds great, I'd  love to see the code... please up load it !
 

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 3 of 58
(18,196 Views)

Sheldon:

 

You may also want to upload it to the games area:

http://www.ni.com/devzone/lvzone/games.htm

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 4 of 58
(18,187 Views)
An older version (LabTRIS) has been floating around for years 😉
Message 5 of 58
(18,173 Views)
Here's the code, I'd appreciate any comments you may have. 
 
I couldn't think of a better way to design the app given that there two different event loops that have to be processed.  Any good ideas to remove the only local variable would be appreciated as well.  I didn't want to set up another communication queue for just the timing local. 
 
I've seen LabTris, but it wasn't working for me (after the first piece, the pieces are invisible), and rather than reverse engineering it, I thought I'd write one from scratch as a learning tool for me, and hopefully a learning tool for my co-workers.
 
Sheldon
Technical geek, engineer, research scientist, biodegradable...
Message 6 of 58
(18,153 Views)
Here's the beginning of some external documentation (I'm always behind on my documentation). 
 
Sheldon 
Technical geek, engineer, research scientist, biodegradable...
Message 7 of 58
(18,144 Views)

Nice share Sheldon!

I have included this thread in the examples listed in the Picture Control discusion that can be found here.

http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=899

I appreciate your posting!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 58
(17,397 Views)

I don't have imaq, and I wanted to build this game...er...tutorial using only the basic LabView elements.  I initially started using picture controls to make a block which was faceted and was comprised of a filled rectangle for the top.  I drew 8 lines around this rectangle set to lighter and darker colors to simulate the lighting of the facets.  The pieces made from these blocks looked really good.  I created a sub-vi to create the block of a given color.  I then drew the board by converting the block picture to a pixmap, then I unflattened the pixmap, and redrew the block at a specified position using "Draw unflattened pixmap".  This worked, and looked quite nice.  But the flattening and redrawing took too much time for this application.  The board was changing (in the mathematical model) while the last state was still being drawn. 

I couldn't find a quick way to do what I wanted to do without going through the flattening kludge.  This method also seems quite slow in terms of performance.  I guess that imaq provides a lot greater pallet of drawing functions that would solve my problem.  However, LabView seems quite slow at doing these sorts of drawing tasks in general, which is unfortunate. 

BTW, I'm working on a network based Pong game...

 

Sheldon

 

Technical geek, engineer, research scientist, biodegradable...
Message 9 of 58
(17,341 Views)

Hi Sheldon,

It sounds like you may be able to compute the images of the blocks ahead of time so that the cumbersome work is only done once. Then while the app is running it just has to to grab the "picture ready" images and stick them were they are required.

I hope this helps and thank you for sharing!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 58
(17,323 Views)