Author Topic: MapConverter(tile ripper next step)  (Read 19538 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
MapConverter(tile ripper next step)
« on: August 28, 2018, 02:08:07 pm »
Ok so moving on with my WarCraft clone, now that I have the Plains tile set, I made this little program to convert the map image to a map array [map(63,63)].

this works nearly exactly like the tile ripper(hell same program even!) but instead of picking the different tiles and putting them to a new layer, this matches the tile set with the map image and stores the tile id in the array then saves the array to a file. right now missed tiles (which there are none with the test map but might be with other maps) are marked 255[FF] in the array though I might have them simply default to a grass tile[0] and be walkable(which is the next step, marking walkable\ nonwalkable tiles)
Code: QB64: [Select]
  1. 'Mapconverter
  2. '2018-08-24 build 0002
  3. map& = _LOADIMAGE("warmap01bkup.PNG", 32)
  4. tile& = _LOADIMAGE("plains2.bmp", 32) '_NEWIMAGE(640, 480, 32)
  5. Zoom& = _NEWIMAGE(128, 128, 32)
  6.  
  7. SCREEN _NEWIMAGE(1024, 480, 32)
  8. DIM SHARED temp(1032) AS _UNSIGNED LONG, Map(64, 64) AS _UNSIGNED _BYTE
  9. CONST TRUE = -1, FALSE = NOT TRUE
  10. CONST Ts = 17 'tile offsets
  11. CONST Tc = 37 'tile count per line
  12. start$ = TIME$
  13.  
  14. peices% = 178
  15.  
  16. FOR Y%% = 0 TO 63
  17.  LINE (0, 400)-(1023, 415), _RGB32(0, 0, 0), BF
  18.  _PUTIMAGE (0, 400), map&, _DISPLAY, (0, 0 + 16 * Y%%)-(1023, 15 + 16 * Y%%)
  19.  
  20.  FOR X%% = 0 TO 63
  21.   'debug information
  22.   LOCATE 10, 1: PRINT peices%; X%%; Y%%
  23.  
  24.   'clear and display progress area
  25.   LINE (0, 416)-(1023, 431), _RGB(0, 0, 0), BF
  26.   LINE (0 + 16 * X%%, 416)-(15 + 16 * X%%, 431), _RGB32(200, 200, 15), BF
  27.  
  28.   _SOURCE map& 'get next test peice
  29.   GET (0 + (X%% * 16), 0 + (Y%% * 16))-(15 + (X%% * 16), 15 + (Y%% * 16)), temp()
  30.   'clear test area
  31.   LINE (300, 180)-(336, 216), _RGB32(0, 0, 0), BF
  32.   'put test peice for reference
  33.   PUT (320, 180), temp()
  34.  
  35.   newtile%% = TRUE
  36.   IF peices% = 0 THEN
  37.   ELSE
  38.    'test the peice placing 2 copies of each found tile and XOR the test peice
  39.    ' over to see if it erases
  40.  
  41.    px%% = 0: py%% = 0
  42.    'first line of found tiles
  43.  
  44.    'cycle through test peices and check for match
  45.    FOR i% = 0 TO peices%
  46.     'progress bar for peices tested
  47.     LINE (0, 360)-(1023, 376), _RGB32(0, 0, 0), BF
  48.     LINE (0 + px%% * Ts, 360)-(15 + px%% * Ts, 375), _RGB32(0, 128, 255), BF
  49.     'current line of tiles to test
  50.     _PUTIMAGE (0, 344), tile&, _DISPLAY, (0, 0 + py%% * Ts)-(639, 15 + py%% * Ts)
  51.  
  52.     LOCATE 11, 1: PRINT i%, px%%, py%%
  53.     'clear test area
  54.     LINE (300, 200)-(336, 216), _RGB32(0, 0, 0), BF
  55.     '    _DELAY .25
  56.  
  57.     'current check image
  58.     LINE (299, 199)-(316, 216), _RGB32(255, 255, 0), B
  59.     _PUTIMAGE (300, 200), tile&, _DISPLAY, (0 + px%% * Ts, 0 + py%% * Ts)-(15 + px%% * Ts, 15 + py%% * Ts)
  60.     '    _DELAY .25
  61.     'place the test copy
  62.     LINE (319, 199)-(336, 216), _RGB32(RND * 255, 255, RND * 255), B
  63.     _PUTIMAGE (320, 200), tile&, _DISPLAY, (0 + px%% * Ts, 0 + py%% * Ts)-(15 + px%% * Ts, 15 + py%% * Ts)
  64.     '    _DELAY .25
  65.  
  66.     'put the tile to check over the test copy with XOR
  67.     PUT (320, 200), temp(), XOR
  68.     'zoom in on that area
  69.     '    _DELAY .25
  70.     _DEST Zoom&
  71.     LINE (0, 0)-(127, 127), _RGB32(0, 0, 0), BF 'clear zoom layer
  72.     _PUTIMAGE (0, 0), _DISPLAY, Zoom&, (299, 200)-(336, 215) 'put test area in zoom layer
  73.     _PUTIMAGE (0, 0)-(128, 64), Zoom&, _DISPLAY, (0, 0)-(37, 15) 'put enlarged image back on display
  74.  
  75.     '    _DELAY .25
  76.     'get the test copy to see if it was erased
  77.     GET (320, 200)-(335, 215), temp(257)
  78.     LOCATE 13, 1: PRINT TileCount2 'rgb brightness value(I think)
  79.     IF INKEY$ = CHR$(27) THEN END
  80.  
  81.     IF TileCount2 <= 256 THEN 'matchfound
  82.      Match% = i%
  83.      i% = peices% + 1
  84.     END IF
  85.     px%% = px%% + 1
  86.     IF px%% = Tc THEN py%% = py%% + 1: px%% = 0
  87.     '    _DELAY .25
  88.    NEXT i%
  89.  
  90.    IF Match% < 255 THEN 'matches found
  91.     LOCATE 12, 1: PRINT TileCount2, Match% 'rgb brightness value(I think)
  92.     '    _DELAY .025
  93.     Map(X%%, Y%%) = Match%
  94.     Match% = 255
  95.    ELSE
  96.     Map(X%%, Y%%) = 255
  97.    END IF
  98.  
  99.   END IF
  100.   '  _DELAY .001
  101.   IF INKEY$ = CHR$(27) THEN Y%% = 65: X%% = 66
  102.   px%% = px%% + 1
  103.   IF px%% = Tc THEN py%% = py%% + 1: px%% = 0
  104.  
  105.  NEXT X%%
  106. NEXT Y%%
  107.  
  108. IF X%% < 65 THEN 'SCREEN tile& 'dont display if user pressed ESC
  109.  ' OPEN "testmap.dat" FOR BINARY AS #1
  110.  ' PUT #1, , Map()
  111.  ' CLOSE
  112. LOCATE 10, 1: PRINT TIME$, start$
  113.  
  114. FUNCTION TileCount
  115.  FOR i% = 1 TO 255
  116.   r~%% = _RED(temp(i%))
  117.   g~%% = _GREEN(temp(i%))
  118.   b~%% = _BLUE(temp(i%))
  119.   v& = v& + (r~%% + b~%% + g~%%)
  120.  NEXT i%
  121.  TileCount = v&
  122.  
  123. FUNCTION TileCount2
  124.  FOR i% = 258 TO 513
  125.   r~%% = _RED(temp(i%))
  126.   g~%% = _GREEN(temp(i%))
  127.   b~%% = _BLUE(temp(i%))
  128.   v& = v& + (r~%% + b~%% + g~%%)
  129.  NEXT i%
  130.  TileCount2 = v&
  131.  

the tile set is actually sorted a bit between walkable and non walkable tiles cause I'm not sure just how I want to accomplish that in the end, use the tiles ID number and have everything > XX be nonwalkable or add a TYPE to the map array and have a IS_Walkable flag.
And so far it all works cause I already have the routine that draws the map back on the screen. This may all seem kind of redundant, cause all I've done is take a image of the map and put it back up. you may be saying "why? you already had the map!" and for this you would be right. but this is simply the example\ research part and isn't a true component of the game, its simply making the "stuff" for the game(which I would still like to come up with a simple\ quick map maker). and to be honest this is often where I will get bored with a project myself cause I'm really not seeing any "game" going on, but I am making progress. This is the first map of the human campaign and will allow me to test the pathfinding and sprite movement. though I need to figure out how to get the sprites to work properly as the not everything happens visibly on the players screen. Units can move out and in of the field of view and trying to figure out just what that code should look like is bogging me down. Also Trying to figure out how to let the pathfinding work even when the unit cannot reach the target(say middle of a batch of trees) but still wanting it to get close to it with out wasting a huge amount of time searching, as the pathfinding routine will keep trying until all possibilities are gone through.
warmap01bkup.png
* warmap01bkup.png (Filesize: 297.4 KB, Dimensions: 1024x1024, Views: 512)
plains2.bmp
* plains2.bmp (Filesize: 900.05 KB, Dimensions: 640x480, Views: 517)
« Last Edit: August 28, 2018, 03:20:55 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: MapConverter(tile ripper next step)
« Reply #1 on: September 10, 2019, 11:47:30 am »
WarCraft2 versions for playing only selected cards are created
and each of 3 versions includes its own language RUS USA FRA
and develops WarCraft2 Wargus wonderful versions see YouTube

used existing files of different versions and clones
plus my cards are compatible with Wargus Stratagus DarkSaga

characters are voiced and video matches language and knowing rules
of registration it is possible to change everything at any time

music: last century and metal cover and new
downloaded separately and unpacked to music

WarCraft2_Program = genaration & modify maps
pudbrowse pudconvert puddle pudpic resview warmaker

links inside YouTube
WarCraft2 MIRACLE Wargus 1600 DANILIN allconsuming worlds


 
WarCraft2_Wargus_RUS_USA_FRA_da78.PNG

 
mir.JPG
« Last Edit: September 10, 2019, 11:48:53 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: MapConverter(tile ripper next step)
« Reply #2 on: February 13, 2021, 04:13:24 am »
Specially for connoisseurs of WarCraft 2

Warcraft2 on screen 1600 about 5 of my maps in 2 minutes

Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Tsar of WarCraft2
« Reply #3 on: April 01, 2021, 02:06:18 am »
My add-on 2MB: SinglePlayer Map 2005... 2020

Tsar of WarCraft2
https://moddb.com/games/warcraft-ii/addons/tsar-of-warcraft2

2MB & milli pictures

 
=tsar88.gif
 
==tsar77.gif
 
=tsar11.gif
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself