MainWindow::MainWindow() { Layout = new QVBoxLayout; GameScene = new QGraphicsScene(); GameScene->setSceneRect(0,0,950,500); GameView = new QGraphicsView(GameScene); ToolBar = new QToolBar(); ScoreLabel = new QLabel("Score: "); ToolBar->addWidget(ScoreLabel); Score = new QLabel("0000"); Score->setFrameStyle( QFrame::StyledPanel | QFrame::Plain ); Score->setAlignment( Qt::AlignCenter ); ToolBar->addWidget(Score); ToolBar->addSeparator(); Health = new QLabel("Health"); ToolBar->addWidget(Health); HealthBar = new QProgressBar(); HealthBar->setValue(100); HealthBar->setTextVisible(false); ToolBar->addWidget(HealthBar); ToolBar->addSeparator(); Start = new QPushButton("START"); ToolBar->addWidget(Start); ToolBar->addSeparator(); Pause = new QPushButton("PAUSE"); Quit = new QPushButton("QUIT"); ToolBar->addWidget(Quit); ToolBar->addSeparator(); Layout->addWidget(GameView); Layout->addWidget(ToolBar); timeInterval = 5; timeCounter = 0; timer = new QTimer(this); timer->setInterval(timeInterval); setLayout(Layout); StartView = new QGraphicsPixmapItem(); StartPic = new QPixmap("Images/Game_StartScreen.png"); StartPicScaled = StartPic->scaled( 1000, 550, Qt::IgnoreAspectRatio, Qt::FastTransformation ); StartView->setPixmap(StartPicScaled); GameScene->addItem(StartView); StartView->setPos(-13, -19); NameBox = new QTextEdit(); NameBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); NameBox->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); NameBox->setFixedHeight(20); NameBox->setFixedWidth(200); GameScene->addWidget(NameBox); NameBox->move(705,422); ////////////////////////// Allocate Main Player Object ///////////////////////// tommy = new Tommy(); HorsePic = new QPixmap("Images/HORSE_1.png"); HorsePic2 = new QPixmap("Images/HORSE_2.png"); HorseScaled = HorsePic->scaled( 150, 150, Qt::IgnoreAspectRatio, Qt::FastTransformation ); HorseScaled2 = HorsePic2->scaled( 150, 150, Qt::IgnoreAspectRatio, Qt::FastTransformation ); leftPosition = false; ////////////////////////// Object Logistics ///////////////////////// bearExists = false; BearCounter = 0; numBears = 0; MAX_BEARS = 3; bearVelocty = .75; srand( time(NULL)); bearStartX = rand()%800 + 800; DPSexists = false; DPSlimit = 40; DPScounter = 0; treeExists = false; treeCounter = 0; treeVelocity = 1.5; devilExists = false; devilCounter = 0; fireballExists = false; duckExists = false; duckCounter = 0; bookExists = false; scoreFactor = .00001; tStart = clock(); ////////////////////////// Connections ///////////////////////// connect(Start, SIGNAL(clicked()), this, SLOT( start() )); connect(Quit, SIGNAL(clicked()), this, SLOT( exit() )); connect(Pause, SIGNAL(clicked()), this, SLOT( pause() )); connect(timer, SIGNAL(timeout()), this, SLOT( scoreCounter() )); connect(timer, SIGNAL(timeout()), this, SLOT( imageRotate() )); connect(timer, SIGNAL(timeout()), this, SLOT( objectAnimate() )); connect(timer, SIGNAL(timeout()), this, SLOT( jumpRegulator() )); connect(timer, SIGNAL(timeout()), this, SLOT( tommyJump() )); connect(timer, SIGNAL(timeout()), this, SLOT( fireballShoot() )); connect(timer, SIGNAL(timeout()), this, SLOT( bookDrop() )); connect(timer, SIGNAL(timeout()), this, SLOT( tommyCollision() )); connect(timer, SIGNAL(timeout()), this, SLOT( addItems() )); connect(timer, SIGNAL(timeout()), this, SLOT( speedUpdater() )); setFocus(); }
int main(int argc, char *argv[]) { FILE *fi, *fo; struct bitmapfile *bf; struct bitmapinfo *bi; struct pixel *pBuffer1, *pBuffer2; int inpWidth, inpHeight, outWidth, outHeight, pixel, row, col; // Open the input image if((fi = fopen(argv[1], "rb")) == NULL) { fprintf(stderr, "Error: Opening file %s\n", argv[1]); return -1; } // Open the output image file if((fo = fopen(argv[2], "wb")) == NULL) { fprintf(stderr, "Error: Opening file %s\n", argv[2]); return -1; } // Allocate memory bf = (struct bitmapfile*)malloc(sizeof(struct bitmapfile)); bi = (struct bitmapinfo*)malloc(sizeof(struct bitmapinfo)); fread(&bf->signature, sizeof(short), 1, fi); fread(&bf->size, sizeof(int), 1, fi); fread(&bf->reserved1, sizeof(short), 1, fi); fread(&bf->reserved2, sizeof(short), 1, fi); fread(&bf->offset, sizeof(int), 1, fi); fread(bi, sizeof(struct bitmapinfo), 1, fi); // Assign width and height inpWidth = bi->width; inpHeight = bi->height; outWidth = bi->height; outHeight = bi->width; bi->width = outWidth; bi->height = outHeight; // Write the headers fwrite(&bf->signature, sizeof(short), 1, fo); fwrite(&bf->size, sizeof(int), 1, fo); fwrite(&bf->reserved1, sizeof(short), 1, fo); fwrite(&bf->reserved2, sizeof(short), 1, fo); fwrite(&bf->offset, sizeof(int), 1, fo); fwrite(bi, sizeof(struct bitmapinfo), 1, fo); // Allocate memory to store the image pBuffer1 = (struct pixel*) malloc(sizeof(struct pixel) * inpWidth * inpHeight); pBuffer2 = (struct pixel*) malloc(sizeof(struct pixel) * inpWidth * inpHeight); fread(pBuffer1, sizeof(struct pixel), inpWidth * inpHeight, fi); imageRotate(pBuffer1, pBuffer2, inpWidth, inpHeight); fwrite(pBuffer2, sizeof(struct pixel), inpWidth * inpHeight, fo); // Deallocate all the memories free(pBuffer1); free(pBuffer2); free(bf); free(bi); // Close all the file pointers fclose(fi); fclose(fo); return 0; }