Jump to content

Making a map!


Recommended Posts

I'm planning on making a game that quizes the user on the capitals and positions of South American countries (eventually all the world once I get to summer...). However, In order to ask a question the computer will randomly highlight one of the countries by making the whole country a specific unique color. Instead of making about 15 different images where each different image has a different color highlighted I was wondering if there was a way to "fill" (like paint does) a certain country.

I have a short example:

GuiCreate('Map of South America', 516, 761) 
GuiCtrlCreatePic(@ScriptDir & '\South America Map.gif', 5, 5, 506, 751) ;Image is attached
GUISetState()

Do 
    Sleep(50) 
Until GuiGetMsg() = -3

post-14131-1179198046_thumb.gif

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I'm planning on making a game that quizes the user on the capitals and positions of South American countries (eventually all the world once I get to summer...). However, In order to ask a question the computer will randomly highlight one of the countries by making the whole country a specific unique color. Instead of making about 15 different images where each different image has a different color highlighted I was wondering if there was a way to "fill" (like paint does) a certain country.

I have a short example:

GuiCreate('Map of South America', 516, 761) 
GuiCtrlCreatePic(@ScriptDir & '\South America Map.gif', 5, 5, 506, 751) ;Image is attached
GUISetState()

Do 
    Sleep(50) 
Until GuiGetMsg() = -3
I suggest you google for floodfill dll, or flood-fill dll.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I'm planning on making a game that quizes the user on the capitals and positions of South American countries (eventually all the world once I get to summer...). However, In order to ask a question the computer will randomly highlight one of the countries by making the whole country a specific unique color. Instead of making about 15 different images where each different image has a different color highlighted I was wondering if there was a way to "fill" (like paint does) a certain country.

I have a short example:

GuiCreate('Map of South America', 516, 761) 
GuiCtrlCreatePic(@ScriptDir & '\South America Map.gif', 5, 5, 506, 751) ;Image is attached
GUISetState()

Do 
    Sleep(50) 
Until GuiGetMsg() = -3
Wont that should be in Example Script forum?

i542

I can do signature me.

Link to comment
Share on other sites

Wont that should be in Example Script forum?

i542

No, he is asking for help.

@Piano_man

I'm not aware of a way to do that in AutoIt unfortunately.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

I suggest you google for floodfill dll, or flood-fill dll.

Do you have any examples of how to use this .dll?

Edit: I mean with autoit, I found some people using this but I don't know how I would translate it to autoit language...

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Maybe an easier way would be to prefill the areas with different colours and then change/swap the colour of the high-lighted area?

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

Maybe an easier way would be to prefill the areas with different colours and then change/swap the colour of the high-lighted area?

I'm not sure what you mean... Would your idea include me having a bunch of different images? 'Cause if not, then I don't know how I would prefill the areas...
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Do you have any examples of how to use this .dll?

Edit: I mean with autoit, I found some people using this but I don't know how I would translate it to autoit language...

I only meant that you should search for floodfill and dll to find a dll which has a floodfill function.

I found this API which I would think could be the best option

floodfill API

but I haven't got ime to play with it now.

Maybe you will find something searching the forum, in particular I suggest you search for posts by Zedna about graphics and drawing because I think he is very good at this sort of thing.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I couldn't get the Floodfill api to work so I've written a dll to do floodfill. I think it will do what Piano Man wants, and could be usefule to someone else.

It has a single function

Function Fill(ctrlHandle,xcoord,ycoord,brushcol,bordercol,ffilltype)

The filltype has to be 1 at the moment untill I either fix or or find it works with 0. (Haven't tried it yet!)

1 means fill the area bordered by colour bodercol, starting at the point xcoord, ycoord, and using a brush colour of brushcol.

Here is a sample program which uses the gif in Piano Man's OP

Documentation is not my forte. To use the program have the dll in the @ScriptDir, change the colour value in the edit box (RGB) to what you want, and click in the area to be filled.

#include <GUIConstants.au3>
Const $FLOODFILLBORDER  = 0, $FLOODFILLSURFACE = 1
Opt("mousecoordmode",2)
$gg = GUICreate("floods",700,800,10,10)
$pic1 = GUICtrlCreatePic("South_America_Map.GIF",0,0, 0,0)
$ed = GUICtrlCreateEdit("ff0000",520,50,170,45)
$ed2 = GUICtrlCreateEdit("",520,100,170,45)
GUICtrlCreateLabel("Fill colour",520,25)
Guisetstate()

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit 
    If $msg = $pic1 Then
        $fcol = Dec(GUICtrlRead($ed))
        
        $mp = MouseGetPos()
        DllCall("floodfill02.dll","int","Fill","hwnd",GUICtrlGetHandle($pic1),"int",$mp[0],"int",$mp[1],"int",$fcol,"int",0,"int",1)
        
    EndIf
    
    $mp = MouseGetPos()
    GUICtrlSetData($ed2,$mp[0] & ', ' & $mp[1])
WEnd

Any suggestions on how I can make the image refresh automatically?

EDIT: Replaced line GuiSetState() which somehow I had deleted.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I couldn't get the Floodfill api to work so I've written a dll to do floodfill. I think it will do what Piano Man wants, and could be usefule to someone else.

Here is working sample for FloodFill without external DLL :)

#include <GUIConstants.au3>

Opt("mousecoordmode",2)

$gui = GuiCreate('Map of South America', 516, 761) 
$pic1 = GuiCtrlCreatePic(@ScriptDir & '\South_America_Map.gif', 5, 5, 506, 751) ;Image is attached
GUISetState()

$pic_hWnd = ControlGetHandle($gui,"",$pic1)
$pic_hdc = DLLCall("user32.dll","int","GetDC","hwnd",$pic_hWnd)

$hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", 0xFF00FF) ; fill color
$obj_orig = DLLCall("gdi32.dll","int","SelectObject","int",$pic_hdc[0],"int",$hBrush[0])

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
    If $msg = $pic1 Then
        $mp = MouseGetPos()
;~         DllCall("floodfill02.dll","int","Fill","hwnd",GUICtrlGetHandle($pic1),"int",$mp[0],"int",$mp[1],"int",0xFF00FF,"int",0,"int",1)
        DllCall("gdi32.dll","int","FloodFill","int",$pic_hdc[0],"int",$mp[0],"int",$mp[1],"int",0x00) ; border color
    EndIf
WEnd

DLLCall("gdi32.dll","int","SelectObject","int",$pic_hdc[0],"int",$obj_orig[0])
DLLCall("gdi32.dll","int","DeleteObject","int",$hBrush[0])

; http://msdn2.microsoft.com/en-us/library/ms532286.aspx
Edited by Zedna
Link to comment
Share on other sites

Here is working sample for FloodFill without external DLL :)

Very good Zedna, that's much better. I couldn't work out how to do that.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 6 months later...
  • 3 months later...

@Zedna: rly big thx dude, i was looking for something like this, but gaved up with the project, now thx to it will be reborned :)

Is There A Life BEFORE Death?im stupidSaved warn logs: cheateraSmOke_N Note Added 17 January 2009 - 02:54 PM Added to warn level Posting a way to hack the registry and force sending someones desktop via TCP. Jos Note Added 25 November 2008 - 02:52 PM Added to warn level for being an impolite rookie.once a year i go bad ... what will happen in 2010??[u]Its GOOD to be BAD ... (Warlock's Succubus - World of Warcraft)[/u]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...