OTFirstClass Posted December 2, 2013 Share Posted December 2, 2013 I recently saw this post on Twitter about this tetris game in javascript in 36 lines of code.I want to use this code but am having problems picking it apart. It is working just fine, but I cannot figure out how to restart the game and go back to the default values after a game ends.The code is at http://jsfiddle.net/ova777/kFxja/ What I have done very simply is to wrap the code in a function startApp() and added a button in the html code that will start the game when clicked. What I want to do is after the game finishes, reset things and restart the game. I do not want to do this via a refresh, but rather set things back to the default. Any help would be greatly appreciated. I have attached my source as well (I have added some CSS styling of my own)Tetris.zip Quote Link to comment Share on other sites More sharing options...
rich Posted December 2, 2013 Share Posted December 2, 2013 If you want to learn how to make your own Tetris game then there are far easier pieces of source code available online to learn from imho. This is cool because it's a tiny mashed-up mess, but it's not so great for learning from. owzim 1 Quote Link to comment Share on other sites More sharing options...
OTFirstClass Posted December 2, 2013 Author Share Posted December 2, 2013 Yes, I know this, but this is nice and short and exactly all I need. If only I could do a reset, I would be happy. Quote Link to comment Share on other sites More sharing options...
Mike Posted December 3, 2013 Share Posted December 3, 2013 If it was a normal coded game, you were going to add the reset functionality as a breeze. Also I want to share a good tutorial how a to make a Tetris Game in ActionScript but hey JavaScript is not so away so it's a good info: http://www.emanueleferonato.com/2011/05/02/creation-of-a-complete-flash-tetris-game/ Quote Link to comment Share on other sites More sharing options...
Mike Posted December 3, 2013 Share Posted December 3, 2013 By the way what you want to do to reset the game is: 1. Null all variables2. Clear the div with class "on" (the bricks) and just call startGame again... and here what I did: http://mihail.ilinov.eu/temp/games/Tetris/ just check the temp.js - and it's still buggy Quote Link to comment Share on other sites More sharing options...
Cappa Games Posted December 4, 2013 Share Posted December 4, 2013 Wow, that's insane. I just released my 2 player Tetris inspired game Blocks VS for Windows 8 and WIndows Phone and I got a hell of a lot more code than that! I gotta go through my code and see how much I can cut down. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.