Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Module Help..

I have created a module called mask that checks if there is a colision inside a circle...
here it is:
Code:
module Mask
  
  def self.circle(x,y,r)
    bottom_x = x
    bottom_y = y
    top_x = x
    top_y = y
    loop do
    for i in -r...r
      # check the bottom half circle
      if self.passable?(bottom_x+i,bottom_y)
        bottom_y - 1 
        r - 1
        if top_y < y + r
          @bottom = true
        end
      else
        @bottom = false
      end
      # check the top half circle
      if self.passable?(top_x+i,top_y)
        top_y + 1
        r - 1
        if top_y > y+r
          @top = true
        end
      else
        @top = false
      end
      if @bottom = true and @top == true
        return true
      else return false
      end
    end
    end
  end

  
  def self.passable?(x,y)
    if $game_map.pixel_passable?(x,y,0, nil,"Tileset")
      return true
    else
      return false
    end
  end
end

But whenever I call it it does shit, nothin happens... Basicly what I want is that it checks if the is one impassable pixel inside the circle with 2*r diameter... Could you please tell me what's wrong?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top