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.

Create a round Minimap

Hi..

uhm.. this request is a bit hard to explain.. so i use a picture as help for you:
http://img389.imageshack.us/img389/2702/hudgrundls5.png[/img]

I want to have a Minimap inside of the great circle left on the HUD Screen.
I thought of making a mask, that lies above a normal quadratic Minimap.. problem: The Mapcorners looked out left and right..

My Question:
Is there a way to cut the Minimap Sprites, so the map fits the circle?


What Map i use:
The Passable Minimap Script.
 

Zeriab

Sponsor

The best way would be to change the actual script itself so it did not draw outside a circle.
Alternatively you can this piece of code which should make everything outside of the biggest possible circle totally transparant.
It is slow, but the area of your circle may be sufficiently small for it to be a feasible solution.
Code:
class Bitmap
  ##
  # Makes all but the largest possible centered circle fully transparent
  # SLOW ~ Zeriab
  #
  def circle!
    color = Color.new(0,0,0,0)
    if self.width < self.height
      radius = self.width / 2
      off_x = 0
      off_y = (self.height / 2) - radius
      fill_rect(0,0,self.width,off_y,color)
      fill_rect(0,self.height-off_y,self.width,off_y,color)
    else
      radius = self.height / 2
      off_x = (self.width / 2) - radius
      off_y = 0
      fill_rect(0,0,off_x,self.height,color)
      fill_rect(self.width-off_x,0,off_x,self.height,color)
    end
    for i in 0...radius*2
      for j in 0...radius*2
        x = i + off_x
        y = j + off_y
        if (x-off_x-radius)**2+(y-off_y-radius)**2 > radius**2
          set_pixel(x,y,color)
        end
      end
    end
  end
end

*hugs*
- Zeriab
 

Zeriab

Sponsor

Zeriab":2vna7thj said:
The best way would be to change the actual script itself so it did not draw outside a circle.
Alternatively you can this piece of code which should make everything outside of the biggest possible circle totally transparant.
It is slow, but the area of your circle may be sufficiently small for it to be a feasible solution.
Code:
class Bitmap
   ...
end

*hugs*
- Zeriab

Look at the bolded text.
The code I have given could also be written in an external language and then compiled to a DLL. If you are lucky you might get someone to do it for you. You could try asking poccil since I believe he has some experience with alterating bitmaps with a DLL.
It would still be better to do as I told before to change the script in question. It might be more complex though.
It is naturally faster to not draw the parts outside of the circles than drawing it first and then removing it. The exception being if you got some kind of hardware support making the other way faster.

I wish you luck with your request ^_^

*hugs*
- Zeriab
 

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