KG_Brad

Members
  • Content count

    128
  • Joined

  • Last visited

Community Reputation

134 Neutral

About KG_Brad

  • Rank
    Member
  1. Metallica kicks ass yet again!

    I like St. Anger as well, it's just not their best.
  2. Metallica has been wrapping up their latest album (Still untitled) and they're giving us all sneak peaks at some of their new material. It's way better than St. Anger. Check it out: www.missionmetallica.com
  3. Strange Segmentation Fault

    It was dividing by zero. I don't know why I didn't think to check that! It's fixed. Thanks!
  4. The following function, when called, causes a segmentation fault: BITMAP *grabframe(BITMAP *src,int w,int h,int sx,int sy,int columns,int frame) { BITMAP *temp = create_bitmap(w,h); int x = sx + frame%columns * w; int y = sy + frame/columns * h; blit(src,temp,x,y,0,0,w,h); return temp; } After much debugging and commenting several lines of code, I narrowed it down to these two lines: int x = sx + frame%columns * w; int y = sy + frame/columns * h; I don't see how this could cause a segmentation fault. What's the problem, here? Also, if it helps, I'm using Dev-C++/gcc. Thank you, -KG_Brad
  5. Tile Based Collision Detection

    Quote:What behavior are you observing? What behavior are you expecting?Sorry about that. I was so burned out on code yesterday and it totally slipped my mind. Basically, what I'm trying to do is check if there will be a collision before it actually happens. Then it determines if the player should move or not by checking if collision is 0 or 1. For some reason, it's only looking for a collision in the lower left hand corner of the "solid" tiles. Also, here's my player.h source: struct { int x; int y; int cell_x; int cell_y; } playerData;
  6. Tile Based Collision Detection

    I hate to double post, but I feel like I need to explain. The reason why my code is bad is because I've never used this collision method. I'm still learning how to do it this way.
  7. Tile Based Collision Detection

    Quote:One last thing - where do you create the playerData instance of whatever struct?In the player.h header file. Quote:On a side note, do you have any particular reason for using C as opposed to C++?No real reason. I just like it better. Quote:Really last thing - playerData.x and playerData.y are the x and y coordinates in pixels, right?Correct. Quote:Also, I assume you meant to index your map in the order (y,x) rather than (x,y)? Are you sure that the way you're indexing the map for collision detection purposes matches the way you're indexing it for rendering?Yes.
  8. Tile Based Collision Detection

    Ok, I split the get_player_cell() function into two functions, one dealing with x, one dealing with y. Here's my source: int find_player_cell_x() { playerData.cell_x = playerData.x/CELLWIDTH; return playerData.cell_x; } int find_player_cell_y() { playerData.cell_y = playerData.y/CELLHEIGHT; return playerData.cell_y; } int collision_detection() { find_player_cell_x(); find_player_cell_y(); if (map[playerData.cell_y][playerData.cell_x] != 0) collision = 1; else collision = 0; return collision; } It's still doing the same thing. Would it help if I made a video to demonstrate what it's doing?
  9. Tile Based Collision Detection

    Quote:I'm assuming this is Cplusplus. Nope. This is C. Quote:First of all, you cannot have 2 return statements in a method like you have. I didn't know that. Fixed. Quote:Second, when you call the find_player_cell() method it will return an int, but you're not doing anything with that int. The collision_detection() function uses it. Quote:Third, your collision_detection() method is of type int, but you have no return statement. I must have left that out of my post. It returns whether or not "collision" is 1 or 0. Quote:I'm guessing that either playerData.x, playerData.cell_x or CELLWIDTH are floats/doubles, or possibly that even if they are ints, the / is doing floating-point division. playerData.x and playerData.y are both ints. CELLWIDTH/HEIGHT is a #define. I'll look into that. Thanks. I'll get on that and if I run into anything else, I'll post it.
  10. I've been working at getting my collision detection fixed for a while, but nothing I'm trying is helping. What I'm trying to do is make a calculation based on the location of the player sprite to determine it's location on my tilemap. Here's my source: int find_player_cell() { playerData.cell_x = playerData.x/CELLWIDTH; playerData.cell_y = playerData.y/CELLHEIGHT; return playerData.cell_x; return playerData.cell_y; } int collision_detection() { find_player_cell(); if (map[playerData.cell_y][playerData.cell_x] != 0) collision = 1; else collision = 0; } It works on some tiles but on others, it doesn't work. What am I missing? Thanks, all!
  11. Programing

    Lately, I've been recommending people with some previous experience to dive right into C. It sounds crazy, but you'll need to learn some form of the language somewhere down the road anyway. IMO, the best option is to just get in there and learn it. Take it at your own pace, however. No need to shoot your foot off (metaphorically and literally speaking :)
  12. Fotomoto?

    Thanks. I think I can find an answer now.
  13. Fotomoto?

    Ok, so lately I've been getting tons of pop-ups, ads, etc. while I'm trying to browse the internet. I figured that some sort of malware downloaded so I did a spyware/adware check with Windows Defender. It came back that I have a "BrowserModifier" called "Fotomoto". Even when I remove it, it keeps coming back for some reason. Does anyone here know about this and if so, what's the solution? Please help me out on this one, KG_Brad
  14. Kevlar Games Forums

    Hey all! Today, I finished setting up the forums for Kevlar Games, my indie-game studio. You can find the forums here: http://s3.invisonfree.com/Kevlar_Games Or by visiting my blog: http://kevgames.blogspot.com Hope to see you there!
  15. John Sheppard is a clone

    I think Jim Byrnes is a clone of Steve Wozniac.