Halosos

62887 pts ยท October 24, 2012


#include <allegro.h> #include <cstdlib> #include <time.h> int ball_x = 320; int ball_y = 240; int ball_tempX = 320; int ball_tempY = 240; int p1_x = 20; int p1_y = 210; int p1_tempX = 20; int p1_tempY = 210; int p2_x = 620; int p2_y = 210; int p2_tempX = 620; int p2_tempY = 210; time_t secs; int dir; BITMAP *buffer; void moveBall(){ ball_tempX = ball_x; ball_tempY = ball_y; if (dir == 1 && ball_x > 5 && ball_y > 5){ if( ball_x == p1_x + 15 && ball_y >= p1_y && ball_y <= p1_y + 60){ dir = rand()% 2 + 3; }else{ --ball_x; --ball_y; } } else if (dir == 2 && ball_x > 5 && ball_y < 475){ if( ball_x == p1_x + 15 && ball_y >= p1_y && ball_y <= p1_y + 60){ dir = rand()% 2 + 3; }else{ --ball_x; ++ball_y; } } else if (dir == 3 && ball_x < 635 && ball_y > 5){ if( ball_x + 5 == p2_x && ball_y >= p2_y && ball_y <= p2_y + 60){ dir = rand()% 2 + 1; }else{ ++ball_x; --ball_y; } } else if (dir == 4 && ball_x < 635 && ball_y < 475){ if( ball_x + 5 == p2_x && ball_y >= p2_y && ball_y <= p2_y + 60){ dir = rand()% 2 + 1; }else{ ++ball_x; ++ball_y; } } else { if (dir == 1 || dir == 3) ++dir; else if (dir == 2 || dir == 4) --dir; } acquire_screen(); circlefill ( buffer, ball_tempX, ball_tempY, 5, makecol( 0, 0, 0)); circlefill ( buffer, ball_x, ball_y, 5, makecol( 128, 255, 0)); draw_sprite( screen, buffer, 0, 0); release_screen(); rest(5); } void p1Move(){ p1_tempY = p1_y; if( key[KEY_W] && p1_y > 0){ --p1_y; } else if( key[KEY_S] && p1_y < 420){ ++p1_y; } acquire_screen(); rectfill( buffer, p1_tempX, p1_tempY, p1_tempX + 10, p1_tempY + 60, makecol ( 0, 0, 0)); rectfill( buffer, p1_x, p1_y, p1_x + 10, p1_y + 60, makecol ( 0, 0, 255)); release_screen(); } void p2Move(){ p2_tempY = p2_y; if( key[KEY_UP] && p2_y > 0){ --p2_y; } else if( key[KEY_DOWN] && p2_y < 420){ ++p2_y; } acquire_screen(); rectfill( buffer, p2_tempX, p2_tempY, p2_tempX + 10, p2_tempY + 60, makecol ( 0, 0, 0)); rectfill( buffer, p2_x, p2_y, p2_x + 10, p2_y + 60, makecol ( 0, 0, 255)); release_screen(); } void startNew(){ clear_keybuf(); readkey(); clear_to_color( buffer, makecol( 0, 0, 0)); ball_x = 320; ball_y = 240; p1_x = 20; p1_y = 210; p2_x = 620; p2_y = 210; } void checkWin(){ if ( ball_x < p1_x){ textout_ex( screen, font, "Player 2 Wins!", 320, 240, makecol( 255, 0, 0), makecol( 0, 0, 0)); startNew(); } else if ( ball_x > p2_x){ textout_ex( screen, font, "Player 1 Wins!", 320, 240, makecol( 255, 0, 0), makecol( 0, 0, 0)); startNew(); } } void setupGame(){ acquire_screen(); rectfill( buffer, p1_x, p1_y, p1_x + 10, p1_y + 60, makecol ( 0, 0, 255)); rectfill( buffer, p2_x, p2_y, p2_x + 10, p2_y + 60, makecol ( 0, 0, 255)); circlefill ( buffer, ball_x, ball_y, 5, makecol( 128, 255, 0)); draw_sprite( screen, buffer, 0, 0); release_screen(); time(&secs); srand( (unsigned int)secs); dir = rand() % 4 + 1; } int main(){ allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0); buffer = create_bitmap( 640, 480); setupGame(); while( !key[KEY_ESC]){ p1Move(); p2Move(); moveBall(); checkWin(); } return 0; } END_OF_MAIN();

MRW I see that the zombies are winning

Points 10
Comments 2
Views 71

Lizard status: Getting nice and warm under his heat lamp

Points 10
Comments 3
Views 13

Lizard status: Sitting on my keyboard being a cute pain in the ass

Points 15
Comments 5
Views 491

lizard status: Still sulking under his shelf

Points 4
Comments 6
Views 440

Lizard status: Stretching his beard

Points 10
Comments 0
Views 400

Lizard status: Hiding behind his log

Points 5
Comments 3
Views 3

Lizard status: Some of his shed has fallen off, he is much happier

Points 6
Comments 12
Views 4

Soak logs in wood.

Points 1883
Comments 56
Views 99787

Lizard status: Chilling under his new UV lamps

Points 16
Comments 0
Views 1

Lizard status: Happy, his shed is peeling

Points 5
Comments 2
Views 6

Dingo's Christmas present

Points 4
Comments 5
Views 344

Lizard status: Watching the world go by

Points 12
Comments 1
Views 1

Lizard status: Dingo is feeling less grumpy, but is still shedding

Points -3
Comments 0
Views 61

Trying to close meatspin

Points 10
Comments 2
Views 477

I took a selfie with a big ol' black hole. Which is different I suppose.

Points 1
Comments 1
Views 80

Lizard staues: Shedding and sulking under his shelf

Points -1
Comments 2
Views 307

He was a great man, he must never be forgotten

Points -2
Comments 16
Views 43

Was playing FO4... God dammit Bethesda

Points 4
Comments 7
Views 57

Maybe want to find a little bit of money? follow the instruction below

Points 10
Comments 1
Views 58

Lizard status: Happy and a little inquisitive

Points 6
Comments 5
Views 2

What the hell am I doing with my life?

Points -7
Comments 2
Views 162

Repeating the same joke, cause no one laughed the first time

Points 20
Comments 1
Views 11837

My bearded dragon dances when he wants to be let out of his tank.

Points 12
Comments 11
Views 310

My favorite gif of all time

Points 23
Comments 10
Views 1308

Merry Christmas, you filthy animal!

Points 9
Comments 1
Views 1757

Are we still doing work stories? Here are some of my most memorable moments from my time as a rock.

Points 29
Comments 16
Views 1879

The front page in a nutshell

Points 3
Comments 10
Views 158

When I get bored of Imgur on the PC, I look at Imgur on my phone. MRW

Points 49
Comments 16
Views 146

Still the 29th in the UK!

Points 11
Comments 0
Views 1

Dingo did not like his new hat

Points 18
Comments 2
Views 46

Lets play a game.

Points -2
Comments 25
Views 31

When you get the emojis just right

Points -5
Comments 0
Views 33

Baby danger floofs are kind of cute, in their own demon-spawn-of-hellish way

Points 19
Comments 7
Views 160

What time is it?

Points 33
Comments 2
Views 191

To avoid accidental spoilers, get this plugin for chrome

Points 1
Comments 1
Views 68

I regret everything

Points -5
Comments 2
Views 104

.

Points 15
Comments 16
Views 303

When someone asks why your reluctant to lend them your phone

Points 3
Comments 8
Views 172

M'lizard

Points 9
Comments 3
Views 260

Who needs drugs when you have fractals.

Points 63
Comments 13
Views 23621

MRW a gypsy curses me

Points 10
Comments 10
Views 199

You see Ivan, when you is attaching the rockets to tank, you are shooting of faster because speed of rocket

Points 1179
Comments 113
Views 34221

living the student life

Points 5
Comments 17
Views 107

My cat yawning.

Points 26
Comments 9
Views 117

HOLY SHIT HOLY SHIT HOLY SHIT

Points 1
Comments 8
Views 262

100 pictures of pizzas

Points 21
Comments 4
Views 618

Why.

Points 24
Comments 7
Views 1

Snaked potato.

Points 63
Comments 12
Views 817

I don't know what I found, but I am sure it should not exist.

Points 16
Comments 11
Views 68

MFW I see the Front Page

Points 8
Comments 0
Views 0

Found this amazing story on Reddit the other day. Its really worth the read.

Points -4
Comments 7
Views 51

My cat likes being combed

Points 1430
Comments 83
Views 33789

Why are you mugging me?!

Points 12
Comments 3
Views 138

Help, there is a danger noodle on my desk!

Points 7
Comments 2
Views 69

The Great Martian War

Points 1494
Comments 65
Views 38647
Next page