Jump to content

Lunar_Drifter

Members
  • Posts

    2181
  • Joined

  • Last visited

Everything posted by Lunar_Drifter

  1. Do you think that the Dungeoneering Cape (true mastery, level 120) will lessen the achievements of some of the more impressive skill capes such as Slayer and the likes? I'm thinking that some of those with the level 120 cape will look down on others who are proud of their Slayer Cape and think, "Meh, mine took 10x the experience that they have invested in that cape.." leading them to think "Stop bragging about your cape!" Or those who don't have the cape will look to those who have Slayer Capes and say "that's not as impressive as Dungeoneering..."
  2. I thought you were done with this thread?... I think they do have some idea as to what their players want, but they could get some more opinions.
  3. With 20k exp per death runes, and people already doing mass RC'ing when they're done with a dungeon, this is going to affect A LOT of people before those people realize that something is up. I think a rollback will be in order because the events happen in isolation, so there's less chance for a mass riot at the scene.
  4. I advise against abusing the RC bug because it will be EASY to detect, and you probably WILL get banned.
  5. The staff has said several times that they did what they wanted to do- get more content for the community with no negative side effects (other than the tedious burden of removing ads :rolleyes:). Jagex said "if you want this, monitor your ads better." If something is mutually beneficial and mutually non-harmful- where's the harm in that?! The problem is not only the ads themselves, it's the facts that- 1. Jagex even thought they should tell fansites what ads they should be having. 2. Jagex dictates that with a carrot and a stick- you do what they want, you get the carrot, you don't- you get the stick. 3. Jagex specified and elaborated on the criteria to grant fansites their ranks, and they didn't mention ads at all. Not only ads are a major part of their measure, it's one of the most influencing- A site that deserves platinum could easily settle for silver ONLY BECAUSE OF THE ADS! Other than that... where do you get your data from? I highly doubt donations are more benificial than ads. I could be wrong, but it seems unlikely. Oh, and admins claimed that changing the ads did not affect revenue. 1. Jagex said which ads they should not be having- which (as I've said), has no effect on the community or any imagined sense of pride. 2. Jagex didn't dictate- they didn't tell us what we were going to do. They offered us some goods based on the condition that we monitor our ads better. Would you disagree to someone giving you money on the terms that you better manage your money? It doesn't harm you in any way to manage your money better, and if your principle is "I don't manage my money because I'm sticking it to the man".. fine, be that way. Don't take the money so you can boost your rebellious-for-the-sake-of-rebellious pride. 3. They could elaborate more on the ads part since it is such a major point. Ad revenue usually isn't much for a site, and I'm sure Tip.It gets more in donations than they do ad revenue (Ad blockers?). It's common sense to me. And your last point solidified my point about the ad revenue not affecting much of anything.
  6. Tip.It gains nothing from specifically running those other gaming ads. The only thing they generate for Tip.It is click-money.. but when they remove particular ads, they are replaced by other ads that generate the same thing! People click them, Tip.It gets a tiny bit of money. Doesn't matter if it's an Evony ad or a Funorb ad. That's where the issue is- people seem to think that those particular ads are beneficial to Tip.It, when in fact they're no more beneficial than the ads that will replace them. The major source of income for Tip.It most likely comes from donations, and the ads don't really benefit us that much in the first place, so replacing one that generates 20 cents with one that generates 10 cents isn't a big deal. Selling out would be if Tip.It gained something beneficial from running those specific ads. There are also no imagined violations of honor or principle or what-have-you. Tip.It did something to benefit its community that had no negative side effects. Certain people think that any dealings with Jagex are to be treated with utmost caution, because Jagex is "the man" and they have a fixation with "sticking it" to "the man."
  7. Can someone answer these questions? I feel like I haven't been answered because you guys realise that your complaints against this skill are completely illogical. This is no less of a skill than slayer. In fact, I see many similarities between it and slayer, in terms of the way the skill works and how you get exp and rewards. Slayer is probably the most popular skill, with a majority of the population in love with it, and also the exp is quite slow and nobody complains about it. Then Jagex releases a skill that is similar to slayer, but more complex and involving, and you guys complain. The way I see it, you being given a random dungeon is exactly parallel to you being given a random task of monsters to kill. You complete the challenge, get exp, and move on to the next random chellenge. There is no logical reason not to like this skill. People complain for complexity, high level rewards, new skills, skill integration, etc.. and when they get it, they complain that it's too complex and too high level. Your parallel to Slayer is spot-on, and I agree with you. However, the naysayers will be naysayers and there is nothing we can do to change their view. It's annoyingly ironic that they complain when they get what they were complaining about not having, but hey.
  8. Good reply Hobhein.. I still don't think that's going to stop qeltar's (and those like him) ranting. Some people can never be satisfied and take things at face value, which is what this case is.
  9. Rune Mysteries doesnt unlock runecrafting, its just a tutorial Oh I was mixed up- I thought the quest gave you access to the altars. Rather, it gives access to the mines. :oops:
  10. You can train Runecrafting in the dungeon without doing Rune Mysteries.. :D I guess they forgot to put that restriction in. I have 7 RC in F2P without doing the quest, all from the altars in there. This will probably get fixed, though. Seems like a simple oversight. (Now, don't hurt me if this was mentioned, I'm not reading all the previous posts).
  11. So I'm having trouble telling if the exp rate is lower for stuff other than RC (RC was already confirmed as reduced?).. I figure that I can craft some runes and train magic in here for free, but is combat exp lowered? I'm still not used to the whole Constitution thing and telling how much exp I should get per hit.
  12. If by that you mean "do you get experience in other skills inside the dungeon", then yes, you do. My question is, is it normal experience for other skills or is it less? Because, if so, this could be a fun new way to train.. I sure was having fun.
  13. qeltar, I've never liked you, and your baseless claims just solidify my dislike, and they solidify your "I don't like Jagex just because they're Jagex, not because they did something wrong this time" stance. Stop arguing with Das- you're wrong. It's not like Tip.It prided itself on adverts anyways, specifically ads for other games. You just argue for the sake of arguing.. I was a bit peeved to see that we weren't on the platinum list, but hey.. we do fine without Jagex anyways.
  14. Yaaah trick, yaah. It's your good ol' buddy Jesse.

    SUP. Saw that your post got locked, because you put it in the wrong spot. Geez what good are you? Just kidding. I think you'll be treated fairly well around here.

  15. Go to make a new account and enter in the user name. It will tell you if it's available or not. Only works for display names, not new accounts.
  16. Somebody check if Moose or Trunks is available. Trunks was the account I wanted to make back in RSC.. and Moose was taken when I made M 0 0 S E. I'm not a member either.. dang.
  17. He definitely said "Zeus's butt hole", which looks nothing like "Jesus." :blink:
  18. You don't need an "unspam" to post on this thread. ;) I try to tell people that ALL THE TIME but nobody listens. Unspam in context of this thread makes me mad.
  19. I got on as a mod with just Windows Firewall/Defender. That was a few years ago though. My #1 security tip is to not be an idiot online. Don't click on suspicious links, don't open emails from unknown senders, and don't fall for those stupid "We won't pay 3.99 for Facebook!" or other action-now scams. Be smart on the internet. Install ad-block if you use Firefox. If you really feel paranoid, then install Web of Trust add-on for Firefox. Speaking of Firefox, don't use Internet Explorer as that is the browser that most hackers/phishers/etc target. Uninstall Adobe Reader and get Foxit, as Adobe has some serious loopholes or so-I've-heard. ESET is good, I use that. You don't need to uninstall torrent software (unless TIF requires you to for the crew). The software won't get you into any trouble, it's what you choose to download that'll do you in. You shouldn't need anything else other than that. It still beats me to this day how people can get viruses so easily. I'm on the internet way more often than the people whose computers I've fixed, and I never (literally) get viruses. I've never had data corruption or stolen passwords or phished accounts.. it just doesn't happen. I guess I know what to look for- so, know what to look for!.
  20. The Tip.it Pulsers. I'm ranked around 19k worldwide, and 60th on TIF's team. 5m keys and 1.5m clicks.
  21. The only non-standard library I've used is allegro for C++. It's very simple to learn, and perfect for simple games.
  22. Preferred language is C++, then Java. Those are the first and last items on my list, which goes to show my expansive knowledge of other languages.
  23. I've settled on restarting the project from scratch with actual planning this time. I just started on that one without planning anything out, so I was just throwing things in there when I needed it. It got confusing after a while though. The way I'm going to do collision now is to test the four corners of each bounding box against each other. The ball and block have their own sets of x1,y1 (top left) and x2,y2 (bottom-right) coordinates. So, it's like: Check if ball's x1 or x2 is somewhere between the block's x1 and x2. Then, check if the ball's y1 or y2 is within the block's y1 and y2. That checks for collision pretty quickly on the top and bottom. Then I just modify that check in a new if statement to check for left-right collision. I split it up like that so I know where exactly the ball is hitting so I can change it's direction accordingly. I think that's a simple enough solution for collision for a simple game! :D
  24. You're right on that, and that should 100% fix why the ball is going through the paddle sometimes. Easy fix, thanks. But I'm looking for help on the collision with the ball hitting a block. The relevant code is in block.cpp.
  25. I'm in the midst of fine-tuning a simple blockbreaker game in C++ using the allegro library for graphics. Everything that I've done so far works as expected, except for the collision. Collision is probably about 85% accurate as of now. The ball hits most blocks just fine, but sometimes- for example- it will go through a block and hit the top side of the block from the inside of the block. Haha.. it's quite unpredictable sometimes. I'll post my source code at the end of this post if anyone wants to check it out. But what I'm asking is for your preferred method of collision detection- how you do it for primitive 2D objects. I'm checking to see if any of the x,y coordinates on the outside of the bounding box of the ball are within the bounding box of the block it's hitting. block.h [hide] #ifndef BLOCK_H #define BLOCK_H #include <allegro.h> typedef enum direction {left, right, up, down, control}; //bX and bY must be declared here so certain functions //can access them. bX and bY refer to the x and y coords //of the ball. extern int bX, bY; extern const int RES_X, RES_Y; extern const int BALL_H, BALL_W; extern direction horiz_dir, vert_dir; extern void ball_hit(direction where); //These are constants pertaining to the //standard parameters of a block, used in //certain constructors where not all the //parameters have been specified. const int BLOCK_STD_W = 60; const int BLOCK_STD_H = 30; const int BLOCK_STD_HEALTH = 1; const int WALL_STD_THICKNESS = 10; const int MAX_BLOCK_ARRAY_SIZE = 40; const int BLOCK_STD_AUTOPLACEMENT_GAP_SIZE = 1; const int BLOCK_STD_AUTOPLACEMENT_START_X = 100; const int BLOCK_STD_AUTOPLACEMENT_START_Y = 100; //block is the struct that contains all the //relevant information pertaining to a block. //a block object can be either destroyable or //or non-destroyable, meaning the struct can //be used for the walls as well. struct sBlock { BITMAP* me; bool canDestroy; int size_h, size_w, pos_x, pos_y, color, health; void init_block(int x, int y); void init_block(int x, int y, char* filename); void init_block(int x, int y, int w, int h); void init_block(int x, int y, int w, int h, int hlth); void init_block(int x, int y, int w, int h, int hlth, int clr); void init_block(int x, int y, int w, int h, int clr, bool d); direction hit_me(); sBlock() { canDestroy = true; size_w = BLOCK_STD_W; size_h = BLOCK_STD_H; pos_x = 50; pos_y = 50; color = 0; health = BLOCK_STD_HEALTH; me = NULL; } }; struct sBlockArray { sBlock* blocks[MAX_BLOCK_ARRAY_SIZE]; BITMAP* l_buffer; int block_autoplacement_x; int block_autoplacement_y; int block_gap; int num_blocks; void read_from_file(char* filename); void init_buffer(int x, int y); void add_block(); void add_block(int x, int y); void add_block(int x, int y, int w, int h); void add_block(int x, int y, int w, int h, int hlth); void add_block(int x, int y, int w, int h, int hlth, int clr); void add_block(int x, int y, int w, int h, int clr, bool d); void draw_blocks(); void update_autoplacement(); void make_walls(int color); void check_collision(); int get_max_blocks(); sBlockArray(int num) { num_blocks = num; for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; ++i) { blocks[i] = new sBlock(); } block_autoplacement_x = BLOCK_STD_AUTOPLACEMENT_START_X; block_autoplacement_y = BLOCK_STD_AUTOPLACEMENT_START_Y; block_gap = BLOCK_STD_AUTOPLACEMENT_GAP_SIZE; } sBlockArray() { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; ++i) { blocks[i] = new sBlock(); } l_buffer = NULL; block_autoplacement_x = BLOCK_STD_AUTOPLACEMENT_START_X; block_autoplacement_y = BLOCK_STD_AUTOPLACEMENT_START_Y; block_gap = BLOCK_STD_AUTOPLACEMENT_GAP_SIZE; } }; #endif [/hide] block.cpp [hide] #include <allegro.h> #include <iostream> #include "block.h" //#define DEBUG //########### //TODO:: // //::sBlockArray::add_block needs to have equal headers //::for each sBlock::init_block function. This way, a //::block may be added and intialized in as many ways as //::there are sBlock::init_block headers, and a block //::can still (re)initialized individually using a call //::to sBlock::init_block. Yay for flexibility. // //::Add functions for: // ::damage_block() ... decrements a destroyable block's // ::health by the current damage factor. // // ::hit_block() ... a call that changes the direction // ::of the ball if it hits that block // // ::draw_blocks() ... function to draw all blocks to // ::the buffer. //########### extern BITMAP* buffer; void sBlock::init_block(int x, int y) { canDestroy = true; size_w = BLOCK_STD_W; size_h = BLOCK_STD_H; pos_x = x; pos_y = y; color = makecol(150,100,100); health = BLOCK_STD_HEALTH; me = create_bitmap(size_w, size_h); rectfill(me, 0, 0, size_w, size_h, color); rect(me, 0, 0, size_w, size_h, color); #ifdef DEBUG std::cout << "Adding block to array.\n"; std::cout << "canDestroy = " << canDestroy << std::endl << "size_w = " << size_w << std::endl << "size_h = " << size_h << std::endl << "pos_x = " << pos_x << std::endl << "pos_y = " << pos_y << std::endl << "color = " << color << std::endl << "health = " << health << std::endl; if ( me == NULL ) std::cout << "me is NULL for some reason..\n"; else std::cout << "me is not NULL.\n"; #endif } void sBlock::init_block(int x, int y, char* filename) { pos_x = x; pos_y = y; health = BLOCK_STD_HEALTH; canDestroy = false; me = load_bitmap(filename, NULL); } void sBlock::init_block(int x, int y, int w, int h) { canDestroy = true; pos_x = x; pos_y = y; size_w = w; size_h = h; color = makecol(255,255,255); health = BLOCK_STD_HEALTH; me = create_bitmap(size_w, size_h); rectfill(me, 0, 0, size_w, size_h, color); rect(me, 0, 0, size_w, size_h, color); #ifdef DEBUG std::cout << "Adding block to array.\n"; std::cout << "canDestroy = " << canDestroy << std::endl << "size_w = " << size_w << std::endl << "size_h = " << size_h << std::endl << "pos_x = " << pos_x << std::endl << "pos_y = " << pos_y << std::endl << "color = " << color << std::endl << "health = " << health << std::endl; if ( me == NULL ) std::cout << "me is NULL for some reason..\n"; else std::cout << "me is not NULL.\n"; #endif } void sBlock::init_block(int x, int y, int w, int h, int hlth) { canDestroy = true; pos_x = x; pos_y = y; size_w = w; size_h = h; color = makecol(255,255,255); health = hlth; me = create_bitmap(size_w, size_h); rectfill(me, 0, 0, size_w, size_h, color); rect(me, 0, 0, size_w, size_h, color); #ifdef DEBUG std::cout << "Adding block to array.\n"; std::cout << "canDestroy = " << canDestroy << std::endl << "size_w = " << size_w << std::endl << "size_h = " << size_h << std::endl << "pos_x = " << pos_x << std::endl << "pos_y = " << pos_y << std::endl << "color = " << color << std::endl << "health = " << health << std::endl; if ( me == NULL ) std::cout << "me is NULL for some reason..\n"; else std::cout << "me is not NULL.\n"; #endif } void sBlock::init_block(int x, int y, int w, int h, int hlth, int clr) { canDestroy = true; pos_x = x; pos_y = y; size_w = w; size_h = h; color = clr; health = hlth; me = create_bitmap(size_w, size_h); rectfill(me, 0, 0, size_w, size_h, color); rect(me, 0, 0, size_w, size_h, color); #ifdef DEBUG std::cout << "Adding block to array.\n"; std::cout << "canDestroy = " << canDestroy << std::endl << "size_w = " << size_w << std::endl << "size_h = " << size_h << std::endl << "pos_x = " << pos_x << std::endl << "pos_y = " << pos_y << std::endl << "color = " << color << std::endl << "health = " << health << std::endl; if ( me == NULL ) std::cout << "me is NULL for some reason..\n"; else std::cout << "me is not NULL.\n"; #endif } void sBlock::init_block(int x, int y, int w,int h, int clr, bool d) { canDestroy = d; pos_x = x; pos_y = y; size_w = w; size_h = h; color = clr; health = BLOCK_STD_HEALTH; me = create_bitmap(size_w, size_h); rectfill(me, 0, 0, size_w, size_h, color); rect(me, 0, 0, size_w, size_h, color); #ifdef DEBUG std::cout << "Adding block to array.\n"; std::cout << "canDestroy = " << canDestroy << std::endl << "size_w = " << size_w << std::endl << "size_h = " << size_h << std::endl << "pos_x = " << pos_x << std::endl << "pos_y = " << pos_y << std::endl << "color = " << color << std::endl << "health = " << health << std::endl; if ( me == NULL ) std::cout << "me is NULL for some reason..\n"; else std::cout << "me is not NULL.\n"; #endif } direction sBlock::hit_me() { for (int curX = bX; curX >= bX && curX <= bX + BALL_W; curX++) { if ( curX >= pos_x && curX <= pos_x + size_w ) { if ( bY <= pos_y + size_h && bY >= pos_y + size_h - 2 ) { if ( vert_dir == up ) { std::cout << "hit bottom of block\n"; health--; return up; } else break; } else if ( bY + BALL_H >= pos_y && bY + BALL_H <= pos_y + 2 ) { if ( vert_dir == down ) { std::cout << "hit top of block\n"; health--; return down; } else break; } } } for (int curY = bY; curY >= bY && curY <= bY + BALL_H; curY++) { if ( curY >= pos_y && curY <= pos_y + size_h ) { if ( bX + BALL_W >= pos_x && bX + BALL_W <= pos_x + 2 ) { if ( horiz_dir == right ) { health--; std::cout << "hit left of block\n"; return right; } else break; } else if ( bX <= pos_x + size_w && bX >= pos_x + size_w - 2 ) { if ( horiz_dir == left ) { std::cout << "hit right of block\n"; health--; return left; } else break; } } } return control; } void sBlockArray::read_from_file(char* filename) { } void sBlockArray::init_buffer(int x, int y) { l_buffer = create_bitmap(x, y); } void sBlockArray::draw_blocks() { if ( l_buffer == NULL ) { std::cerr << "l_buffer is NULL!\n"; return; } clear_to_color(l_buffer, makecol(255,0,255)); for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->health <= 0 && blocks[i]->canDestroy == true ) blocks[i]->me = NULL; if ( blocks[i]->me != NULL ) { blit(blocks[i]->me, l_buffer, 0, 0, blocks[i]->pos_x, blocks[i]->pos_y, blocks[i]->size_w, blocks[i]->size_h); } } } void sBlockArray::update_autoplacement() { if ( (block_autoplacement_x + BLOCK_STD_W) < (RES_X - BLOCK_STD_AUTOPLACEMENT_START_X) ) block_autoplacement_x += BLOCK_STD_W + block_gap; else { block_autoplacement_x = BLOCK_STD_AUTOPLACEMENT_START_X; block_autoplacement_y += block_gap + BLOCK_STD_H; } } void sBlockArray::add_block() { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->me == NULL ) { blocks[i]->init_block(block_autoplacement_x, block_autoplacement_y); update_autoplacement(); break; } } } void sBlockArray::add_block(int x, int y) { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->me == NULL ) { blocks[i]->init_block(x, y); update_autoplacement(); break; } } } void sBlockArray::add_block(int x, int y, int w, int h) { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->me == NULL ) { blocks[i]->init_block(x, y, w, h); update_autoplacement(); break; } } } void sBlockArray::add_block(int x, int y, int w, int h, int hlth) { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->me == NULL ) { blocks[i]->init_block(x, y, w, h, hlth); update_autoplacement(); break; } } } void sBlockArray::add_block(int x, int y, int w, int h, int hlth, int clr) { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->me == NULL ) { blocks[i]->init_block(x, y, w, h, hlth, clr); update_autoplacement(); break; } } } void sBlockArray::add_block(int x, int y, int w, int h, int clr, bool d) { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]->me == NULL ) { blocks[i]->init_block(x, y, w, h, clr, d); update_autoplacement(); break; } } } void sBlockArray::make_walls(int color) { add_block(0, 0, WALL_STD_THICKNESS, RES_Y, color, false); add_block((RES_X-WALL_STD_THICKNESS), 0, WALL_STD_THICKNESS, RES_Y, color, false); add_block(0, 0, RES_X, WALL_STD_THICKNESS, color, false); } void sBlockArray::check_collision() { for (int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { if ( blocks[i]-> me != NULL ) ball_hit(blocks[i]->hit_me()); } } int sBlockArray::get_max_blocks() { return MAX_BLOCK_ARRAY_SIZE; } [/hide] main.cpp [hide] #include <allegro.h> #include <iostream> #include "block.h" /*######## //TODO:: //::Figure out a new way to detect collision with stuff. // //::Separate the logic of the game into its own function //::that will call helper functions to move the game along //::a step. // //::Implement a ball damage factor so the ball could do //::more or less damage according to different multipliers. //######## */ //RES_X and RES_Y control the resolution of the screen. //They are set as global variables so that positions can //be calculated according to the screen size and not //to a fixed position. const int RES_X = 640; const int RES_Y = 480; //PADDLE_W and PADDLE_H refer to the height and width //of the paddle. These constants are used in calculations //regarding the paddle. //BALL_W and BALL_H refer to the height and width of the ball, //available here for universal calculations regarding the ball. //MOVESPEED controls how fast the paddle will move. It should //stay an even number so as to keep calculations precise. const int PADDLE_W = 75; const int PADDLE_H = 20; const int BALL_W = 20; const int BALL_H = 20; const int MOVESPEED = 8; const int BALL_SPEED_X_MAX = 5; const int BALL_SPEED_Y_MAX = 5; const int BALL_SPEED_X_MIN = -4; const int BALL_SPEED_Y_MIN = 2; //pX and pY make up the current x and y position of the paddle //in relation to the screen. By default, the coordinates are //set to have the paddle appear in the bottom middle of the screen. //pLB and pRB are the left and right bounds of the paddle respectively. //bX and bY form the x and y coordinates of the ball. int pX = (RES_X/2) - (PADDLE_W/2); int pY = RES_Y - (RES_Y/12); int pLB = pX; int pRB = pLB + PADDLE_W; int bX = (RES_X/2) - (BALL_W/2); int bY= pY - 20; int ball_speed_x = 4; int ball_speed_y = 4; int ball_speed_multiplier = 1; direction horiz_dir = right; direction vert_dir = up; //BITMAP pointers are declared here so they can be used in any function //without having to pass them by reference each time. This way, the //BITMAP objects will be accessible by all functions inherently. BITMAP* buffer; BITMAP* paddle; BITMAP* ball; //sBlockArray level holds the array of blocks for each level. sBlockArray level; sBlockArray walls; //these are essentially state flags that are set and reset when //certain events occur. bool gameStarted = false; bool gamePaused = false; bool lifeLost = false; //testing function void test_structs() { for ( int i = 0; i < MAX_BLOCK_ARRAY_SIZE; i++) { level.add_block(); } } //gfx_init() initializes the graphics in one place so as to //tidy up the code and not clutter main() with all the graphics. void gfx_init() { PALETTE pal; allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, RES_X, RES_Y, 0, 0); paddle = load_bitmap("paddle.bmp", pal); ball = load_bitmap("ball.bmp", pal); buffer = create_bitmap(RES_X, RES_Y); level.init_buffer(RES_X, RES_Y); test_structs(); level.draw_blocks(); walls.init_buffer(RES_X, RES_Y); walls.make_walls(makecol(0,50,150)); walls.draw_blocks(); masked_blit(walls.l_buffer, buffer, 0, 0, 0, 0, RES_X, RES_Y); masked_blit(level.l_buffer, buffer, 0, 0, 0, 0, RES_X, RES_Y); masked_blit(paddle, buffer, 0, 0, pX, pY, PADDLE_W, PADDLE_H); masked_blit(ball, buffer, 0, 0, bX, bY, BALL_W, BALL_H); blit(buffer, screen, 0, 0, 0, 0, RES_X, RES_Y); } //redraw() clears the buffer and reconstructs it, then draws //it to the screen. void redraw() { clear_bitmap(buffer); level.draw_blocks(); walls.draw_blocks(); masked_blit(walls.l_buffer, buffer, 0, 0, 0, 0, RES_X, RES_Y); masked_blit(level.l_buffer, buffer, 0, 0, 0, 0, RES_X, RES_Y); masked_blit(paddle, buffer, 0, 0, pX, pY, PADDLE_W, PADDLE_H); rect(ball, 0, 0, BALL_W-1, BALL_H-1, makecol(0,255,0)); masked_blit(ball, buffer, 0, 0, bX, bY, BALL_W, BALL_H); textprintf_ex(buffer, font, 2, 2, makecol(255,255,255), -1, "ball_speed_x: %d", ball_speed_x); textprintf_ex(buffer, font, 2, 10, makecol(255,255,255), -1, "ball_speed_y: %d", ball_speed_y); textprintf_ex(buffer, font, 2, 18, makecol(255,255,255), -1, "bX = %d bY = %d", bX, bY); textprintf_ex(buffer, font, 2, 26, makecol(255,255,255), -1, "horiz_dir = %d vert_dir = %d", horiz_dir, vert_dir); blit(buffer, screen, 0, 0, 0, 0, RES_X, RES_Y); } //ball_hit() is called when the ball comes into contact //with the something, resulting in the ball changing directions //according to the ball's position relative to the position //of the object. void ball_hit(direction where) { if ( where == up ) { ball_speed_y = ball_speed_y * (-1); vert_dir = down; return; } else if ( where == down ) { ball_speed_y = ball_speed_y * (-1); vert_dir = up; return; } else if ( where == left ) { ball_speed_x *= -1; horiz_dir = right; return; } else if ( where == right ) { ball_speed_x *= -1; horiz_dir = left; return; } else return; } //used when pausing the game, shows the menu and stops the ball //from moving. void game_pause() { } void check_hit_paddle() { if ( bX + (BALL_W/2) >= pX && bX + (BALL_W/2) <= pX + PADDLE_W && bY + BALL_H >= pY && bY + BALL_H <= pY + 2 ) //if ( bY >= pY ) { if ( bX + (1/2)*BALL_W <= pLB + (1/3)*PADDLE_W ) { std::cout << ":::: hit left of paddle\n"; //ball_speed_x = std::max(BALL_SPEED_X_MIN, ball_speed_x - 1); ball_hit(down); return; } else if ( bX + (1/2)*BALL_W >= pRB - (1/3)*PADDLE_W ) { std::cout << ":::: hit right of paddle\n"; //ball_speed_x = std::min(BALL_SPEED_X_MAX, ball_speed_x + 1); ball_hit(down); return; } std::cout << ":::: hit middle of paddle\n"; ball_hit(down); } } //ball_move() controls the movement of the ball. void ball_move() { if ( gameStarted && !gamePaused ) { bX += ball_speed_x; bY -= ball_speed_y; } } //game_init() is called at the beginning of the game to set up //the state flags and do the initial "hit" on the ball. void game_init() { if ( gameStarted == true ) return; else { gameStarted = true; gamePaused = false; lifeLost = false; ball_move(); } } int main() { gfx_init(); while ( !key[KEY_ESC] ) { vsync(); if ( key[KEY_LEFT] ) { if ( pLB - 4 > 0 ) { pX -= MOVESPEED; pLB -= MOVESPEED; pRB -= MOVESPEED; } } else if ( key[KEY_RIGHT] ) { if ( pRB + 4 < RES_X ) { pX += MOVESPEED; pRB += MOVESPEED; pLB += MOVESPEED; } } if ( key[KEY_SPACE] ) { if ( gameStarted == false ) game_init(); else game_pause(); } if ( gameStarted && !gamePaused ) { redraw(); check_hit_paddle(); walls.check_collision(); level.check_collision(); ball_move(); } } return 0; } END_OF_MAIN(); [/hide]
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.