• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
    17
  • comments
    30
  • views
    17494

Trickier than I thought

Sign in to follow this  
Followers 0
DareDeveloper

596 views

Combining the logic of Tetris and 2048 is trickier than I thought.

Not even figuring out what I want the program to do ...
the logic gets more and more complex and the special cases are a nuisance.

What I have so far is tiles that can penetrate tiles with the same number, tiles that merge when a block collides while same-number-tiles are on top of each other ...

http://www.procgames.com/demos/notprocatall.html

... and the beginning of freshly merged tiles staying active.

http://www.procgames.com/demos2/notprocatall.html

The biggest problem is the approach I picked:
the current block is modified and contains only the merged tiles, while the other tiles (collided ones and numbers that are not stacked) are put into the game field and stay stationary.

The remaining block keeps moving as long as it does not collide, but that is still too strict.
The tiles should trickle down independently until all of them have collided.

I thought using the existing block collision method was a smart thing to do, because I want the player to have control over the new pseudo-block.
That would be doable, but the problem is that within a round there should be several collision tests now (will the merged tile move in the next round, or is it not alive any more?) ... which really does not quite fit ...[code=js:0]GameStateDefault.prototype.update = function(gameContext) { this.isMovingBlocked = false; this.frameAge += this.getFrameDuration(); if (this.frameAge > this.getTurnDuration()) { this.frameAge = 0; this.handleNextTurnEvent(gameContext); this.copyFieldToCanvas(); this.copyBlockToCanvas(); gameContext.clearRect(0,0,640,500); gameContext.fillStyle = "#edc22e"; gameContext.font = "bold 20px Arial"; // this.gameplayField.draw(gameContext); // this.gameplayBlock.draw(gameContext); var indexX; var indexY; for (indexY = 0; indexY < this.fieldHeight; indexY++) { for (indexX = 0; indexX < this.fieldWidth; indexX++) { this.drawTileAndMerges(this.getXOffset(), 0, indexX, indexY, this.canvasArray[indexY][indexX], this.mergeArray[indexY][indexX], gameContext); } } this.previewBlock.drawAt(this.getXOffset() + (this.gameplayField.width * this.getTilesize()) + 10, 10, gameContext); } this.frameCount++;}
...[code=js:0]GameStateDefault.prototype.checkForCollisions = function(gameContext) { // var message = "this.gameplayBlock.isRigid: " + this.gameplayBlock.isRigid; // var aliveCount = 0; var blockPosX = this.gameplayBlock.posX; var newBlockPosY = this.gameplayBlock.posY + 1; var gameplayBlockArray = this.gameplayBlock.blockArray; var indexX; var indexY; for (indexY = 0; indexY < gameplayBlockArray.length; indexY++) { var fieldIndexY = this.gameplayBlock.posY + indexY; for (indexX = 0; indexX < gameplayBlockArray.length; indexX++) { var fieldIndexX = this.gameplayBlock.posX + indexX; if (TILETYPE_NONE != gameplayBlockArray[indexY][indexX]) { if (this.fieldHeight <= (newBlockPosY + indexY)) { //if (this.gameplayBlock.isRigid) { return 1; //} else { //this.gameplayField.gameArray[fieldIndexY][fieldIndexX] = gameplayBlockArray[indexY][indexX]; //gameplayBlockArray[indexY][indexX] = TILETYPE_NONE; //} } else { if (TILETYPE_NONE != this.gameplayField.gameArray[newBlockPosY + indexY][blockPosX + indexX]) { if (gameplayBlockArray[indexY][indexX] != this.gameplayField.gameArray[newBlockPosY + indexY][fieldIndexX]) { //if (this.gameplayBlock.isRigid) { return 1; //} else { //if (this.gameplayField.gameArray[fieldIndexY][fieldIndexX] == gameplayBlockArray[indexY][indexX]) { // gameplayBlockArray[indexY][indexX] *= 2; // this.gameplayField.gameArray[fieldIndexY][fieldIndexX] = TILETYPE_NONE; // aliveCount++; //} else { // gameplayBlockArray[indexY][indexX] = TILETYPE_NONE; // this.gameplayField.gameArray[fieldIndexY][fieldIndexX] = gameplayBlockArray[indexY][indexX]; //} //} //} else { //aliveCount++; } } } } } } // showMessage(message); //if ((false == this.gameplayBlock.isRigid) && (0 == aliveCount)) { //return 1; //} return 0;}
...[code=js:0]GameStateDefault.prototype.handleMerges = function(gameContext) { var mergeCount = 0; var gameplayBlockArray = this.gameplayBlock.blockArray; // var activeTilesBlockArray = this.activeTilesBlock.blockArray; // this.activeTilesBlock.posX = this.gameplayBlock.posX; // this.activeTilesBlock.posY = this.gameplayBlock.posY; var indexX; var indexY; for (indexY = 0; indexY < gameplayBlockArray.length; indexY++) { for (indexX = 0; indexX < gameplayBlockArray.length; indexX++) { if (gameplayBlockArray[indexY][indexX] != TILETYPE_NONE) { if (gameplayBlockArray[indexY][indexX] != this.gameplayField.gameArray[this.gameplayBlock.posY + indexY][this.gameplayBlock.posX + indexX]) { this.gameplayField.gameArray[this.gameplayBlock.posY + indexY][this.gameplayBlock.posX + indexX] = gameplayBlockArray[indexY][indexX]; gameplayBlockArray[indexY][indexX] = TILETYPE_NONE; } else { this.gameplayField.gameArray[this.gameplayBlock.posY + indexY][this.gameplayBlock.posX + indexX] = TILETYPE_NONE; gameplayBlockArray[indexY][indexX] = (2 * gameplayBlockArray[indexY][indexX]); this.gameplayBlock.isRigid = false; mergeCount++; } } } } return mergeCount;}
The weekend is approaching, though ... so I am confident that I will think of something ... soon enough smile.png

0
Sign in to follow this  
Followers 0


3 Comments


Interesting, I ran into a case where pushing down caused the block to move through other blocks.  I had myself a tower that sprouted up, like a T shape, and pressing down while over an edge of the T causes pieces to fall through.

1

Share this comment


Link to comment

Good idea to try out html5 with something simple. Yeah, the game logic is pretty muddy, I don't see any interesting strategies. Smooth animation would help... if you do that you might have to rethink your collision code... which could solve your dilemma or convince you to try something completely different, hehe.

1

Share this comment


Link to comment

Interesting, I ran into a case where pushing down caused the block to move through other blocks.  I had myself a tower that sprouted up, like a T shape, and pressing down while over an edge of the T causes pieces to fall through.

I have tried to reproduce that ... did not work even with pressing down multiple times.

Probably it is a weird scenario. There are a lot of funky things going on, though.

Thanks for checking it out. I like your physics based Tower Defense btw.

 

Good idea to try out html5 with something simple. Yeah, the game logic is pretty muddy, I don't see any interesting strategies. Smooth animation would help... if you do that you might have to rethink your collision code... which could solve your dilemma or convince you to try something completely different, hehe.

Simple was the idea ... and I think I have already spent too much time considering the goals.

I'll write another post soon with a link to a final version, but I think I am moving on to either WebGL or another planning stage now ...

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now