Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

106 Neutral

About boblehest

  • Rank
  1. boblehest

    Card Zone placement problem

    Ok, that's kinda what I assumed, it just didn't make sense to me that the 2 if blocks set different y values (I assume those are x/y values for the card position), since if they're on the same row, they should have the same y value, right? sprite_index=spr_mini sound_play(snd_summon) if not  collision_point(x, y, obj_mzone1,1,1) { x = 339; y = 326; } // The last part of this is redundant, you just checked if not collision_point for mzone1 above, if that failed, then there was a collision. // There is no need to check again                             v else if not  collision_point(x, y, obj_mzone2,1,1) and collision_point(x, y, obj_mzone1,1,1) { x = 416; y = 400; // why is this not 326 as well? } First, I don't know why your code fails to work the way you intended, I don't think you provided all the relevant code (I don't know Game Maker though.) Now for some pseudo code for a better approach: // I don't know how you organize your objects in Game Maker, so I'm kinda coding while blind here. // Somewhere, you should have stored information about zone sizes, and on screen positions. // You should never use your objects' on screen positions to "store" information. I hope you can see the difference here.   // Store these variables somewhere.. spell_zone_slots = 5; spell_zone_base_x = 339; spell_zone_spacing = 80; // Horizontal space between cards spell_zone_base_y = 326; spell_zone_slots_taken = 0;   // card_id would be some identification for that specific card instance. function add_card_to_spell_zone(card_id) {   if (spell_zone_slots_taken >= spell_zone_slots) {     // No more room, do whatever return;   } ? // In case you need to check which card is in slot x, you can check spell_zone_cards[x]. I don't know if you need to or not.   spell_zone_cards[spell_zone_slots_taken] = card_id;   card_id.x = spell_zone_base_x + spell_zone_spacing * spell_zone_slots_taken;   card_id.y = spell_zone_base_y;     spell_zone_slots_taken += 1; } I hope you get the concept here. Store the slot state in variables so you know what slots are taken, you should not have to check for any collision for this.
  2. boblehest

    Card Zone placement problem

    You should probably follow some tutorials, because your approach is a bit misguided. I could tell you straight away that collision checking is just a very bad approach to this problem, and that you should be using arrays here.
  3.   I wouldn't make a habit of depending on implementation defined behavior like that.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!