Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by dima ( 14 years ago )
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MH 30
#define MW 20
#define MB 4
#define MR 4
#define CSHIFT 1000
#define C_Empty -1
#define C_Line 99

struct coo
{
    int x, y;
};
struct map
{
    struct coo block[MB];
};
struct figdata
{
    int blocks, rots;
    struct map rot[MR];
};
int room[MH][MW];
int heigh, width;
void show();
void init();
void drawblock(int x);
void drawfig(int bit);
void clearroom();
void down();
void rotate();
void newfig();
void checklines();
void drawnext();
void quick_throw();
void move(int dx);
int canstay(int fig, int rot, int x, int y);
struct figdata data(int fig);

int lines_collected, score;
struct { int x, y, fig, rot;} cur;
struct { int fig, rot;} next;

int main()
{
    int key = CSHIFT;
    unsigned ctime = time(NULL);
    init();
    show();
    do
    {
        if (kbhit())
        {
            key = getch();
            if(key==224 | key==0) key = (int) getch() + (int) CSHIFT;
            switch(key)
            {
                case 72+CSHIFT : rotate(); break;
                case 75+CSHIFT : move(-1); break;
                case 77+CSHIFT : move(+1); break;
                case 80+CSHIFT : down();   break;
                case ' '       : quick_throw();
               // default : printf("%d\n",key);
            }
        }
        if (time(NULL) != ctime)
        {
            ctime = time(NULL);
            down();
        }
    } while(key!=27);
    return 0;
}

void init()
{
    srand( (unsigned int) time(NULL));
    lines_collected = score = 0;
    heigh = 20;
    width = 10;
    clearroom();
    next.fig = rand()%7;
    next.rot = rand()

 

Revise this Paste

Parent: 51617
Children: 51619
Your Name: Code Language: