Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

XoniX Game wall coloring problem

Community Beginner ,
Aug 21, 2013 Aug 21, 2013

Hello,

I'm working at the XoniX game at the moment

the idea of the game is simple multiple enemies are moving in the room , you have to build the walls to make their room smaller

the actual problem is that I want to fill the color when the wall is built

I have made this so far

https://appswithssl.com/xonix/

here you can move the player with w,a,s,d and if you go from one wall to another the shape is drawn

xonix.jpg

TOPICS
ActionScript
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 24, 2013 Aug 24, 2013

you don't need to find the shortest way.  you just need to find one interior point of the quad and then use the bitmapdata's floodfill method.  actually, you don't even need to find which sprites constitute the quad.  you can create a bitmap of them all and use floodfill and the point(s) that are interior.

Translate
Community Expert ,
Aug 21, 2013 Aug 21, 2013

in general, what you want to do is difficult. 

first, you have to determine whether you have a closed polygon.  then you have to determine which points are inside and which points are outside the polygon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 21, 2013 Aug 21, 2013

thank you for the answer,

i have already an algorithm about a closed polygon, the problem is deteoning points, which are inside the polygon and another which are the edges of a polygon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2013 Aug 21, 2013

what's the algorithm?  do you have a link?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 22, 2013 Aug 22, 2013

this is just a simple thing,

at first I am checking if the player isn't on a wall and if true I start tracking it's movement,

each time it changes the direction  I store the position of a point where the direction was changed in an array , untill the player intersects or hits the wall

i detect a hit/intersection and begin to draw the lines using the points I stored and than I store all the new walls in a wall array and it works pretty well

only problem I have is filling the shapes with a color

the whole game so far is here

https://appswithssl.com/xonix/xonix.zip

p.s. sorry for the controls it is with arrow keys and not with wasd

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 22, 2013 Aug 22, 2013

are you creating a new sprite each time you change direction and use that sprite's graphics property to draw the line and then use those sprites in your hittest?  if so, you determine which sprites constitiute your polygon, use the bitmapdata draw method to create a bitmap of your polygon and then fill that bitmap.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 23, 2013 Aug 23, 2013

thank you very much for your attention,I am trying exactly that, I am trying to figure out which edges or dots complete a new shape to draw the polygon using lineto and begifill,

if I only had an algorithm which would figure it out ((

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2013 Aug 23, 2013

you don't need to do that.  you just need to determine which sprites/lines constitute part of your polygon.  you can then use the bitmapdata class to draw a new bitmap of that filled polygon.  you can then add that filled polygon to your display (under your lines).

determining those sprites should be straight-forward (at least using brute force).  in general this could be wildly unwieldly and inpractical, but in a flash app with a very limited number of lines this should not be unworkable.

when you have a positive hittest, you have the start and end sprites/lines.  the start sprite has a positive hittest with, at least, one other sprite (that's not the end sprite).  save those (potential 2nd leg of the polygon) sprites.  each of those has a positive hittest with, at least, 1 other sprite that's not the start sprite.  save those (potential 3rd leg of the polygon) sprites. etc until one of the potential legs has a positive hittest with the end sprite.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 24, 2013 Aug 24, 2013

thank you sooo much, that should solve my problem

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 24, 2013 Aug 24, 2013

but there is still left something I must find a shortest way, which is a little bit difficult to figure out.

if i choose the wrong polygon I will fill allready filled one too

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2013 Aug 24, 2013

you don't need to find the shortest way.  you just need to find one interior point of the quad and then use the bitmapdata's floodfill method.  actually, you don't even need to find which sprites constitute the quad.  you can create a bitmap of them all and use floodfill and the point(s) that are interior.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 26, 2013 Aug 26, 2013

May I call you - my Hero?

thanks for telling me about floodfill function )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2013 Aug 26, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines