The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Hanoi
Posted by: KURWACZ | April 5, 2011 @ 1:47pm
C Code
[
Download
]
#include <stdio.h> #include <math.h> #include <unistd.h> #include "primlib.h" /* - Program Definition - */ #define PEG 3 #define BLOCK 11 int drawPeg(); int drawBlock(); /* - Program Body - */ int main(void) { drawPeg(); SDL_Delay(1000); drawBlock(); SDL_Delay(3000); return 0; } /* - Function Drawing Peg's - */ int drawPeg(void) { int tempWidth; int tempHeight; int loopCount = 1; if (initGraph()) exit(1); filledRect(0, 0, screenWidth()-1, screenHeight()-1, BLACK); do{ tempWidth = screenWidth()/(PEG+1); tempWidth = tempWidth * loopCount; tempHeight = screenHeight()/(BLOCK+1); filledRect(tempWidth-2, tempHeight, tempWidth+2, screenHeight()-30, RED); loopCount++; SDL_Delay(50); }while(loopCount < (PEG+1)); updateScreen(); return 1; } /* - Function Drawing Block's - */ int drawBlock(void) { /* 0 Stand for no block, 1 biggest, 2 smaller etc */ int pegBlock[PEG][BLOCK]; int setup = 0; int firstLoop = 1; int secondLoop = 1; int blockLocX; int blockWidth = 0; int blockLocY; int blockHeight = screenHeight()/(BLOCK +1); /* - Fill the first Peg with Blocks - */ for(setup = 0; setup < BLOCK; setup++) { pegBlock[0][setup] = BLOCK - setup; } if (initGraph()) exit(1); filledRect(0, 0, screenWidth()-1, screenHeight()-1, BLACK); do{ do{ blockLocX = screenWidth()/(PEG+1); blockLocX = blockLocX * firstLoop; blockLocY = screenHeight()/(BLOCK+1); blockLocY = blockLocY * secondLoop; blockHeight = blockHeight / 10; blockWidth = (pegBlock[firstLoop][secondLoop] * 2) + 2; if(pegBlock[firstLoop][secondLoop] != 0) { filledRect(blockLocX - blockWidth, blockLocY - blockHeight, blockLocX + blockWidth, blockLocY + blockHeight, BLUE); } secondLoop++; }while(secondLoop < (BLOCK+1)); firstLoop++; }while(firstLoop < (PEG+1)); updateScreen(); return 1; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.48 / 8
23 Votes
http://codebin.yi.org/1201
page generated in 0.01 seconds