/************************************************************* * Function: animateDices () * * Date Created: September 29, 2012 * * Date Last Modified: September 29, 2012 * * Description: This function simulates the two dices being * * rolled and prints out random dices on screen * * Input parameters: values for die one and die two * * Returns: void * * Preconditions: Random function is working properly and * * values for die one and two to be received * * were randomly selected. Windows.h must be * * included for Sleep () and Beep () * * Postconditions: Outputs selected two dices on the screen * *************************************************************/ void animateDices (int dieOne, int dieTwo) { int i = 0; /* counter */ for (i = 0; i < DICE_NUMBER_OF_ROTATION; i++) { /* Clears the screen */ system ("cls"); /* Prints the title on top of the screen */ printTitle (); /* Outputs 2 simulated dice on the screen based from the generated random number */ drawDie (getRandomNumber (6)); printf ("\n"); drawDie (getRandomNumber (6)); /* Makes a beep sound */ Beep (523, 300); /* Pauses the program */ Sleep (300); } system ("cls"); printTitle (); drawDie (dieOne); printf ("\n"); drawDie (dieTwo); printf ("\n"); Beep (659, 200); }
static void drawObject(int x, int y) { OBJ_T *pObj = &field[y][x]; /* Blank */ if (pObj->type == OBJ_TYPE_BLANK) { drawFloorOrBlank(x, y, 6 - (pObj->rotate) * 3); return; } /* Floor */ bool isFlash = (vanishFlashFrames > 0 && (vanishFlg[y] & 1 << x)); if (pObj->type == OBJ_TYPE_FLOOR || blinkFlg && !isFlash && pObj->depth >= DEPTH_MAX / 2 && (pObj->mode == OBJ_MODE_APPEAR || pObj->mode == OBJ_MODE_VANISH)) { drawFloorOrBlank(x, y, 0); return; } /* Die */ int d = min(pObj->depth / (DEPTH_MAX / (DEPTH_PIXEL + 1)), DEPTH_PIXEL); int dx = x * GRID_PIXEL + 24 + d; int dy = y * GRID_PIXEL + 4 + d; if (isFlash) { drawObjectBitmap(dx, dy, IMG_OBJ_DIE_MASK, WHITE); } else { bool isWhite = (pObj->mode == OBJ_MODE_FIXED || pObj->mode == OBJ_MODE_VANISH && !blinkFlg); drawDie(dx, dy, pObj->type, pObj->rotate, isWhite); } }
static void drawCursor(void) { int dx = cursorX * GRID_PIXEL + 24; int dy = cursorY * GRID_PIXEL; int imgId = gameFrames % 10; if (imgId >= 5) imgId = 10 - imgId; arduboy.drawBitmap(dx - 1, dy - 1, imgCursorMask[imgId], 14, 8, BLACK); arduboy.drawBitmap(dx, dy, imgCursor[imgId], 12, 6, WHITE); OBJ_T obj = field[cursorY][cursorX]; if (obj.type >= OBJ_TYPE_1 && obj.type <= OBJ_TYPE_6) { drawDie(108, 0, obj.type, obj.rotate, false); } else { drawObjectBitmap(108, 0, IMG_OBJ_DIE_DUMMY, WHITE); } arduboy.drawBitmap(109, 17, imgLabelInfo, 13, 5, WHITE); }