mirror of https://github.com/buggins/dlangui.git
tetris example update
This commit is contained in:
parent
b52284a7fc
commit
666c27edf1
|
@ -108,12 +108,15 @@ Win32 builds
|
||||||
* Executable size for release Win32 API based build is 830K.
|
* Executable size for release Win32 API based build is 830K.
|
||||||
|
|
||||||
|
|
||||||
Build and run using DUB:
|
Build and run demo app using DUB:
|
||||||
|
|
||||||
git clone https://github.com/buggins/dlangui.git
|
git clone https://github.com/buggins/dlangui.git
|
||||||
cd dlangui
|
cd dlangui
|
||||||
dub run dlangui:example1 --build=release
|
dub run dlangui:example1 --build=release
|
||||||
|
|
||||||
|
Run Tetris game example
|
||||||
|
|
||||||
|
dub run dlangui:tetris --build=release
|
||||||
|
|
||||||
To develop using Visual-D, download sources for dlabgui and dependencies into some directory:
|
To develop using Visual-D, download sources for dlabgui and dependencies into some directory:
|
||||||
|
|
||||||
|
|
|
@ -281,6 +281,32 @@ class CupWidget : Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rotate(int delta) {
|
||||||
|
int newOrientation = (_currentFigureOrientation + 4 + delta) & 3;
|
||||||
|
if (isPositionFree(_currentFigure, newOrientation, _currentFigureX, _currentFigureY)) {
|
||||||
|
if (_state == CupState.FallingFigure && !isPositionFree(_currentFigure, newOrientation, _currentFigureX, _currentFigureY - 1)) {
|
||||||
|
if (isPositionFreeBelow())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_currentFigureOrientation = newOrientation;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool move(int deltaX) {
|
||||||
|
int newx = _currentFigureX + deltaX;
|
||||||
|
if (isPositionFree(_currentFigure, _currentFigureOrientation, newx, _currentFigureY)) {
|
||||||
|
if (_state == CupState.FallingFigure && !isPositionFree(_currentFigure, _currentFigureOrientation, newx, _currentFigureY - 1)) {
|
||||||
|
if (isPositionFreeBelow())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_currentFigureX = newx;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected void onAnimationFinished() {
|
protected void onAnimationFinished() {
|
||||||
switch (_state) {
|
switch (_state) {
|
||||||
case CupState.NewFigure:
|
case CupState.NewFigure:
|
||||||
|
@ -288,7 +314,6 @@ class CupWidget : Widget {
|
||||||
setState(CupState.HangingFigure, 75);
|
setState(CupState.HangingFigure, 75);
|
||||||
break;
|
break;
|
||||||
case CupState.FallingFigure:
|
case CupState.FallingFigure:
|
||||||
// TODO
|
|
||||||
if (isPositionFreeBelow()) {
|
if (isPositionFreeBelow()) {
|
||||||
_currentFigureY--;
|
_currentFigureY--;
|
||||||
setState(CupState.HangingFigure, 75);
|
setState(CupState.HangingFigure, 75);
|
||||||
|
@ -300,7 +325,6 @@ class CupWidget : Widget {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CupState.HangingFigure:
|
case CupState.HangingFigure:
|
||||||
// TODO
|
|
||||||
setState(CupState.FallingFigure, 25);
|
setState(CupState.FallingFigure, 25);
|
||||||
break;
|
break;
|
||||||
case CupState.DestroyingRows:
|
case CupState.DestroyingRows:
|
||||||
|
|
Loading…
Reference in New Issue