Author Topic: CLEARCOLOR not working.(figured out)  (Read 4640 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
CLEARCOLOR not working.(figured out)
« on: September 01, 2018, 12:10:31 pm »
As the subject line says, I find myself in a situation where it appears that CLEARCOLOR wont work. Not completely as I have 2 layers that are is working and 2 layers where it is not working. In this code the layers that work are LOADIMAGE handles so I've tried to do the same with the layers that were not working but it still doesn't act right.
so in the demo here what is going on is, the layer for the drawn map(62) is placed first then the sprite layer(63) that has the peasant on it then the main window(HUMAN) is on top. then it repeats. I have added delays so you can see the series of events, without an epileptic seizure hopefully, and watch as the map layer erases the window layer, then the map layer gets erased by the sprite layer but the window layer doesn't erase the sprite layer. so the window layer's clear color of 0,0,0 is working but the other two layers that have the same clearcolor of 0,0,0 is not. (and if you just have drawsprite itself on top of something the background color of the peasant sprite sheet(224,224,224) is also clear and works properly.)

Maybe its some nuance with clearcolor I'm not picking up or I've missed something in-between.
Code: QB64: [Select]
  1. 'WarCraft 64
  2. '2018-08-29 00:10
  3. 'last update 01:30 2018-09-01
  4. 'Build Count 0013
  5. 'Kobolt
  6. '
  7. 'Routine
  8. 'SetPath (Path() AS Coord, StartPos AS Coord, TargetPos AS Coord, Map())
  9. '  -Path()   - the array for the path found from StartPos to TargetPos   [UNITS.PATH()]
  10. '  -StartPos - the Begining Location of the unit                         [Unit().Movement.MapX, Unit().Movement.MapY]
  11. '  -TargetPos- where the player clicked the mouse to have unit reach     [MapClick.X, MapClick.Y]
  12. '  -Map()    - the map array to search for a path in                     [Map()]
  13. '
  14. 'Loadlayers()
  15. '  -Load sprite and tile sheets
  16. '
  17. 'MapDrawer (Lx%, Ly%, Sx~%%, Sy~%%, Scale%%, Sets%%, Lay%%)
  18. '  -Lx%,Ly%    - screen pos to draw map
  19. '  -Sx~%%,Sy~%%- start pos to read map data
  20. '  -Scale%%    - tile size to display 1x or 2x
  21. '  -Sets%%     - Tile Set to use, Plains[26] or Swamp[0] (and maybe Cave)
  22. '  -Lay%%      - layer to draw map on
  23. '
  24. 'DrawSprite(Lx%, Ly%,Mx~%%, My~%%, Scale%%, D%%)
  25. '  -Draws a Units sprites
  26. '  -Lx%,Ly%    - screen pos to draw sprite
  27. '  -Mx~%%,My~%%- Current start pos of the map being displayed
  28. '  -Scale%%    - sprite size to display 1x or 2x
  29. '  -D%%        - Destination layer to draw sprite on
  30.  
  31.  
  32. TYPE PathCoord
  33.  pos AS Coord ' Coordinates of position on map
  34.  parent AS Coord ' Coordinates of previous position on path
  35.  g AS INTEGER ' G cost value
  36.  h AS INTEGER ' H cost value
  37.  f AS INTEGER ' F = G + H (total movement cost)
  38.  status AS INTEGER ' 0 for unsearched, 1 for open, 2 for closed (explored)
  39.  
  40. TYPE SpriteData
  41.  IDmark AS _BYTE '    which sprite is it (1-Unit(0), 2-Peon ect...)
  42.  MapX AS _BYTE '      current Map square occupied
  43.  MapY AS _BYTE '      current Map square occupied
  44.  xloc AS SINGLE '     screen x location
  45.  yloc AS SINGLE '     screen y location
  46.  MoveAngle AS SINGLE 'direction sprite is moving
  47.  MoveSpeed AS SINGLE 'speed at which sprite is moving
  48.  Direction AS _BYTE ' sprite image faceing direction
  49.  Frame AS _BYTE '     which frame of animation sprite is on
  50.  Is_Moving AS _BYTE '  is the unit currently moving?
  51.  PathID AS _UNSIGNED _BYTE '
  52.  
  53. TYPE UnitData
  54.  Movement AS SpriteData 'inherited data
  55.  HP AS _UNSIGNED _BYTE ' a unit hit tolerance, includeing buildings and resources
  56.  HPM AS _UNSIGNED _BYTE 'a units max hit tolerance
  57.  Armor AS _BYTE '        units defence from an attack
  58.  Range AS _BYTE '        distance a unit can attack from
  59.  DamLo AS _BYTE '        minimal damage a unit can do
  60.  DamHi AS _BYTE '        Maximum damage a unit can do
  61.  CostG AS INTEGER '      Gold cost of unit to be produced
  62.  CostW AS INTEGER '      Wood Cost of unit to be produced
  63.  Act AS _BYTE '          is unit moving, mining, chopping wood, attacking, carrying wood or gold
  64.  Build AS _BYTE '        Time in seconds to build unit Based on Normal Speed X2.25 on slowest  X0.45 Fastest
  65.  
  66. TYPE StructureData
  67.  Structure AS SpriteData '   not all elements used
  68.  HP AS _UNSIGNED INTEGER '   a structures remaining hit tolerance
  69.  HPM AS _UNSIGNED INTEGER '  a structures Max hit tolerance
  70.  Gold AS _UNSIGNED INTEGER ' a mines remaining gold reserve
  71.  
  72. TYPE MapAttrib
  73.  TileId AS _UNSIGNED _BYTE
  74.  Is_Walkable AS _BYTE
  75.  
  76. TYPE Gamedata
  77.  MapX AS _BYTE 'top left corner of the area of map the player
  78.  MapY AS _BYTE ' is currently veiwing
  79.  
  80. CONST TRUE = -1, FALSE = NOT TRUE 'Duh and DUH
  81. CONST Ts = 17, Tc = 37 'tile box size, tile count per line
  82. 'action constants
  83. CONST Still = 0, Moving = 1, Mining = 2, LumberJack = 3, Attacking = 4, CarryWood = 5
  84. CONST CarryGold = 6, Shooting = 7, Casting = 8, Decomposing = 9, Removal = 10
  85. 'Direction constants
  86. CONST North = 0, NorthEast = 1, East = 2, SouthEast = 3, South = 4, SouthWest = 5, West = 6, NorthWest = 7
  87. 'Unit Constants
  88. CONST Peasant = 1, Peon = 2, Footman = 3, Grunt = 4, Archer = 5, Spearman = 6, Knight = 7, Raider = 8
  89. CONST Cleric = 9, Necrolyte = 10, Conjurer = 11, Warlock = 12, SkeletonO = 13, Skeleton = 14
  90. CONST Deamon = 15, WaterElemt = 16, FireElemt = 17, Lothar = 18
  91. 'Tile sets
  92. CONST Plains = 26, Swamp = 0, Cave = 28
  93. 'Player screens
  94. CONST Human = 27, Orc = 28
  95. 'Game Tile\Sprite scaling
  96. CONST Scaling = 2
  97.  
  98. DIM SHARED Map(63, 63) AS MapAttrib
  99. DIM SHARED Unit(255) AS UnitData, Units.Path(512) AS Coord
  100. DIM SHARED Anima(32, 7) AS _BYTE 'movement animation sequince
  101. DIM SHARED Game AS Gamedata
  102.  
  103. DIM Path(2048) AS Coord '' Dimension array of path coords to be filled in later
  104. DIM startpos AS Coord, targetpos AS Coord
  105.  
  106. LoadLayers
  107. FOR AnimaA%% = 0 TO 2
  108.  FOR AnimaB%% = 0 TO 7
  109.   READ Anima(AnimaA%%, AnimaB%%)
  110.  
  111. OPEN "testmap.dat" FOR BINARY AS #1
  112. GET #1, , Map()
  113.  
  114. SCREEN _NEWIMAGE(640, 480, 32)
  115. _CLEARCOLOR _RGB32(224, 224, 224), Layer(Peasant) 'works
  116. _CLEARCOLOR _RGB32(0, 0, 0), Layer(62) 'does not work?
  117. _CLEARCOLOR _RGB32(0, 0, 0), Layer(63) 'does not work?
  118. _CLEARCOLOR _RGB32(0, 0, 0), Layer(Human) 'works
  119.  
  120.  
  121. startpos.x = 40: startpos.y = 21
  122. targetpos.x = 24: targetpos.y = 33
  123.  
  124. SetPath Path(), startpos, targetpos, Map()
  125.  
  126. Unit(0).Movement.xloc = 320
  127. Unit(0).Movement.yloc = 200
  128. Unit(0).Movement.Direction = North
  129. Unit(0).Movement.IDmark = Peasant
  130. Unit(0).Act = Moving
  131. Unit(0).Movement.MapX = startpos.x
  132. Unit(0).Movement.MapY = startpos.y
  133. _PUTIMAGE (0, 0), Layer(Human), _DISPLAY
  134. Game.MapX = 30
  135. Game.MapY = 20
  136.  
  137. FOR i% = 2 TO Path(0).x
  138.  'figure out spirte facing direction
  139.  'the units MapX\Y are the previous location and Path is the next location
  140.  IF Unit(0).Movement.MapX > Path(i%).x AND Unit(0).Movement.MapY = Path(i%).y THEN Unit(0).Movement.Direction = West
  141.  IF Unit(0).Movement.MapX < Path(i%).x AND Unit(0).Movement.MapY = Path(i%).y THEN Unit(0).Movement.Direction = East
  142.  IF Unit(0).Movement.MapX = Path(i%).x AND Unit(0).Movement.MapY > Path(i%).y THEN Unit(0).Movement.Direction = North
  143.  IF Unit(0).Movement.MapX = Path(i%).x AND Unit(0).Movement.MapY < Path(i%).y THEN Unit(0).Movement.Direction = South
  144.  IF Unit(0).Movement.MapX > Path(i%).x AND Unit(0).Movement.MapY > Path(i%).y THEN Unit(0).Movement.Direction = NorthWest
  145.  IF Unit(0).Movement.MapX > Path(i%).x AND Unit(0).Movement.MapY < Path(i%).y THEN Unit(0).Movement.Direction = SouthWest
  146.  IF Unit(0).Movement.MapX < Path(i%).x AND Unit(0).Movement.MapY > Path(i%).y THEN Unit(0).Movement.Direction = NorthEast
  147.  IF Unit(0).Movement.MapX < Path(i%).x AND Unit(0).Movement.MapY < Path(i%).y THEN Unit(0).Movement.Direction = SouthEast
  148.  
  149.  'find units on screen location
  150.  Unit(0).Movement.xloc = (Unit(0).Movement.MapX - Game.MapX) * (16 * Scaling)
  151.  Unit(0).Movement.yloc = (Unit(0).Movement.MapY - Game.MapY) * (16 * Scaling)
  152.  FOR F% = 0 TO 7
  153.   _DEST Layer(62): LINE (0, 0)-(639, 399), _RGB32(0, 0, 0), BF
  154.   _DEST Layer(63): LINE (0, 0)-(639, 399), _RGB32(0, 0, 0), BF
  155.   MapDrawer 144, 24, Game.MapX, Game.MapY, Scaling, Plains, 62
  156.   DrawSprite 144, 24, Game.MapX, Game.MapY, Scaling, 63
  157.   _PUTIMAGE (0, 0)-(639, 399), Layer(62), _DISPLAY
  158.   _DELAY .5
  159.   _PUTIMAGE (0, 0)-(639, 399), Layer(63), _DISPLAY
  160.   _DELAY .5
  161.   _PUTIMAGE (0, 0)-(639, 399), Layer(Human), _DISPLAY
  162.   _DELAY .5
  163.   IF INKEY$ = CHR$(27) THEN END
  164.  NEXT F%
  165.  'MapDrawer 144, 24, Game.MapX, Game.MapY, Scaling, Plains, _DISPLAY
  166.  'DrawSprite 144, 24, Game.MapX, Game.MapY, Scaling, _DISPLAY
  167.  _DELAY .1
  168.  'update units pos
  169.  Unit(0).Movement.MapX = Path(i%).x
  170.  Unit(0).Movement.MapY = Path(i%).y
  171. NEXT i%
  172.  
  173. '$include:'Movementdata.bi'
  174.  
  175. '$include:'Loadlayers.bi'
  176. '$include:'Warpath.bi'
  177. '$include:'MapDrawer.bi'
  178. '$include:'DrawSprite.bi'
  179.  
there is the main code, and below is the package of components needed to test it.
« Last Edit: September 02, 2018, 08:49:35 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: CLEARCOLOR not working.
« Reply #1 on: September 01, 2018, 01:07:35 pm »
Hi Cobalt. I repair something in drawsprite.bi and something in your bas file in _Putimage loop . Look at it, if it solve your problem.


Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: CLEARCOLOR not working.
« Reply #2 on: September 01, 2018, 01:26:09 pm »
yes and no, that may look like it fixed that one issue but has created a host of other issues, I add the minimap display and it wont show up, the peasants shadow is now gone again, none of the debug information will display.. in fact nothing else shows up anymore beyond what is in that loop(even if i put it in that loop it still wont show)..  yeah..  not going to beable to use that solution. thank you though.

though looking at it differently made me realize I don't need to constantly remake the map layer, only if the player shifts the area to be displayed. not that it has any baring on this issue but should make a difference in the long run, thanks again.
« Last Edit: September 01, 2018, 01:29:22 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: CLEARCOLOR not working.
« Reply #3 on: September 01, 2018, 01:35:16 pm »
J've looked at your program very quickly, I do not understand the context in such a short time, but the main problem, as I understand it, is that drawing SPRITE is still on the same screen that is then inserted all over. In order to disappear the previously drawn scene, I gave it before the new drawing of CLS. I do not know what is being rendered there, it is possible that something else is drawn on the same screen before moving. That's what the author knows. :-D It's in DrawSprite.BI, clearcolor took it correctly. Those commands setalpha what I added to the BAS file are unnecessary.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: CLEARCOLOR not working.
« Reply #4 on: September 01, 2018, 01:43:25 pm »
Yeah.... give back  MapDrawer call in to FOR NEXT loop in bas file...

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: CLEARCOLOR not working.
« Reply #5 on: September 01, 2018, 01:46:09 pm »
but the main problem, as I understand it, is that drawing SPRITE is still on the same screen that is then inserted all over. In order to disappear the previously drawn scene,

no, the problem was that each layer erased the previous even though the CLEARCOLOR was set, it was as if the CLEARCOLOR was not what I set it to.
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: CLEARCOLOR not working.
« Reply #6 on: September 01, 2018, 02:01:46 pm »
 I do not know why, but I learned to use the CLEARCOLOR commands as close as possible to the PUTIMAGE command. This has always proved to be good. I attach a resource in which I only corrected what I really wanted (in my opinion), with the DrawSprite.BI file from the previous attachment that works the way you wanted.

Code: QB64: [Select]
  1. 'WarCraft 64
  2. '2018-08-29 00:10
  3. 'last update 01:30 2018-09-01
  4. 'Build Count 0013
  5. 'Kobolt
  6. '
  7. 'Routine
  8. 'SetPath (Path() AS Coord, StartPos AS Coord, TargetPos AS Coord, Map())
  9. '  -Path()   - the array for the path found from StartPos to TargetPos   [UNITS.PATH()]
  10. '  -StartPos - the Begining Location of the unit                         [Unit().Movement.MapX, Unit().Movement.MapY]
  11. '  -TargetPos- where the player clicked the mouse to have unit reach     [MapClick.X, MapClick.Y]
  12. '  -Map()    - the map array to search for a path in                     [Map()]
  13. '
  14. 'Loadlayers()
  15. '  -Load sprite and tile sheets
  16. '
  17. 'MapDrawer (Lx%, Ly%, Sx~%%, Sy~%%, Scale%%, Sets%%, Lay%%)
  18. '  -Lx%,Ly%    - screen pos to draw map
  19. '  -Sx~%%,Sy~%%- start pos to read map data
  20. '  -Scale%%    - tile size to display 1x or 2x
  21. '  -Sets%%     - Tile Set to use, Plains[26] or Swamp[0] (and maybe Cave)
  22. '  -Lay%%      - layer to draw map on
  23. '
  24. 'DrawSprite(Lx%, Ly%,Mx~%%, My~%%, Scale%%, D%%)
  25. '  -Draws a Units sprites
  26. '  -Lx%,Ly%    - screen pos to draw sprite
  27. '  -Mx~%%,My~%%- Current start pos of the map being displayed
  28. '  -Scale%%    - sprite size to display 1x or 2x
  29. '  -D%%        - Destination layer to draw sprite on
  30.  
  31.  
  32. TYPE PathCoord
  33.     pos AS Coord ' Coordinates of position on map
  34.     parent AS Coord ' Coordinates of previous position on path
  35.     g AS INTEGER ' G cost value
  36.     h AS INTEGER ' H cost value
  37.     f AS INTEGER ' F = G + H (total movement cost)
  38.     status AS INTEGER ' 0 for unsearched, 1 for open, 2 for closed (explored)
  39.  
  40. TYPE SpriteData
  41.     IDmark AS _BYTE '    which sprite is it (1-Unit(0), 2-Peon ect...)
  42.     MapX AS _BYTE '      current Map square occupied
  43.     MapY AS _BYTE '      current Map square occupied
  44.     xloc AS SINGLE '     screen x location
  45.     yloc AS SINGLE '     screen y location
  46.     MoveAngle AS SINGLE 'direction sprite is moving
  47.     MoveSpeed AS SINGLE 'speed at which sprite is moving
  48.     Direction AS _BYTE ' sprite image faceing direction
  49.     Frame AS _BYTE '     which frame of animation sprite is on
  50.     Is_Moving AS _BYTE '  is the unit currently moving?
  51.     PathID AS _UNSIGNED _BYTE '
  52.  
  53. TYPE UnitData
  54.     Movement AS SpriteData 'inherited data
  55.     HP AS _UNSIGNED _BYTE ' a unit hit tolerance, includeing buildings and resources
  56.     HPM AS _UNSIGNED _BYTE 'a units max hit tolerance
  57.     Armor AS _BYTE '        units defence from an attack
  58.     Range AS _BYTE '        distance a unit can attack from
  59.     DamLo AS _BYTE '        minimal damage a unit can do
  60.     DamHi AS _BYTE '        Maximum damage a unit can do
  61.     CostG AS INTEGER '      Gold cost of unit to be produced
  62.     CostW AS INTEGER '      Wood Cost of unit to be produced
  63.     Act AS _BYTE '          is unit moving, mining, chopping wood, attacking, carrying wood or gold
  64.     Build AS _BYTE '        Time in seconds to build unit Based on Normal Speed X2.25 on slowest  X0.45 Fastest
  65.  
  66. TYPE StructureData
  67.     Structure AS SpriteData '   not all elements used
  68.     HP AS _UNSIGNED INTEGER '   a structures remaining hit tolerance
  69.     HPM AS _UNSIGNED INTEGER '  a structures Max hit tolerance
  70.     Gold AS _UNSIGNED INTEGER ' a mines remaining gold reserve
  71.  
  72. TYPE MapAttrib
  73.     TileId AS _UNSIGNED _BYTE
  74.     Is_Walkable AS _BYTE
  75.  
  76. TYPE Gamedata
  77.     MapX AS _BYTE 'top left corner of the area of map the player
  78.     MapY AS _BYTE ' is currently veiwing
  79.  
  80. CONST TRUE = -1, FALSE = NOT TRUE 'Duh and DUH
  81. CONST Ts = 17, Tc = 37 'tile box size, tile count per line
  82. 'action constants
  83. CONST Still = 0, Moving = 1, Mining = 2, LumberJack = 3, Attacking = 4, CarryWood = 5
  84. CONST CarryGold = 6, Shooting = 7, Casting = 8, Decomposing = 9, Removal = 10
  85. 'Direction constants
  86. CONST North = 0, NorthEast = 1, East = 2, SouthEast = 3, South = 4, SouthWest = 5, West = 6, NorthWest = 7
  87. 'Unit Constants
  88. CONST Peasant = 1, Peon = 2, Footman = 3, Grunt = 4, Archer = 5, Spearman = 6, Knight = 7, Raider = 8
  89. CONST Cleric = 9, Necrolyte = 10, Conjurer = 11, Warlock = 12, SkeletonO = 13, Skeleton = 14
  90. CONST Deamon = 15, WaterElemt = 16, FireElemt = 17, Lothar = 18
  91. 'Tile sets
  92. CONST Plains = 26, Swamp = 0, Cave = 28
  93. 'Player screens
  94. CONST Human = 27, Orc = 28
  95. 'Game Tile\Sprite scaling
  96. CONST Scaling = 2
  97.  
  98. DIM SHARED Map(63, 63) AS MapAttrib
  99. DIM SHARED Unit(255) AS UnitData, Units.Path(512) AS Coord
  100. DIM SHARED Anima(32, 7) AS _BYTE 'movement animation sequince
  101. DIM SHARED Game AS Gamedata
  102.  
  103. DIM Path(2048) AS Coord '' Dimension array of path coords to be filled in later
  104. DIM startpos AS Coord, targetpos AS Coord
  105.  
  106. LoadLayers
  107. FOR AnimaA%% = 0 TO 2
  108.     FOR AnimaB%% = 0 TO 7
  109.         READ Anima(AnimaA%%, AnimaB%%)
  110.     NEXT
  111.  
  112. OPEN "testmap.dat" FOR BINARY AS #1
  113. GET #1, , Map()
  114.  
  115. SCREEN _NEWIMAGE(640, 480, 32)
  116. _CLEARCOLOR _RGB32(224, 224, 224), Layer(Peasant) 'works
  117. _CLEARCOLOR _RGB32(0, 0, 0), Layer(62) 'does not work?
  118. _CLEARCOLOR _RGB32(0, 0, 0), Layer(63) 'does not work?
  119. _CLEARCOLOR _RGB32(0, 0, 0), Layer(Human) 'works
  120.  
  121.  
  122. startpos.x = 40: startpos.y = 21
  123. targetpos.x = 24: targetpos.y = 33
  124.  
  125. SetPath Path(), startpos, targetpos, Map()
  126.  
  127. Unit(0).Movement.xloc = 320
  128. Unit(0).Movement.yloc = 200
  129. Unit(0).Movement.Direction = North
  130. Unit(0).Movement.IDmark = Peasant
  131. Unit(0).Act = Moving
  132. Unit(0).Movement.MapX = startpos.x
  133. Unit(0).Movement.MapY = startpos.y
  134. _PUTIMAGE (0, 0), Layer(Human), _DISPLAY
  135. Game.MapX = 30
  136. Game.MapY = 20
  137.  
  138. FOR i% = 2 TO Path(0).x
  139.     'figure out spirte facing direction
  140.     'the units MapX\Y are the previous location and Path is the next location
  141.     IF Unit(0).Movement.MapX > Path(i%).x AND Unit(0).Movement.MapY = Path(i%).y THEN Unit(0).Movement.Direction = West
  142.     IF Unit(0).Movement.MapX < Path(i%).x AND Unit(0).Movement.MapY = Path(i%).y THEN Unit(0).Movement.Direction = East
  143.     IF Unit(0).Movement.MapX = Path(i%).x AND Unit(0).Movement.MapY > Path(i%).y THEN Unit(0).Movement.Direction = North
  144.     IF Unit(0).Movement.MapX = Path(i%).x AND Unit(0).Movement.MapY < Path(i%).y THEN Unit(0).Movement.Direction = South
  145.     IF Unit(0).Movement.MapX > Path(i%).x AND Unit(0).Movement.MapY > Path(i%).y THEN Unit(0).Movement.Direction = NorthWest
  146.     IF Unit(0).Movement.MapX > Path(i%).x AND Unit(0).Movement.MapY < Path(i%).y THEN Unit(0).Movement.Direction = SouthWest
  147.     IF Unit(0).Movement.MapX < Path(i%).x AND Unit(0).Movement.MapY > Path(i%).y THEN Unit(0).Movement.Direction = NorthEast
  148.     IF Unit(0).Movement.MapX < Path(i%).x AND Unit(0).Movement.MapY < Path(i%).y THEN Unit(0).Movement.Direction = SouthEast
  149.  
  150.     'find units on screen location
  151.     Unit(0).Movement.xloc = (Unit(0).Movement.MapX - Game.MapX) * (16 * Scaling)
  152.     Unit(0).Movement.yloc = (Unit(0).Movement.MapY - Game.MapY) * (16 * Scaling)
  153.     FOR F% = 0 TO 7
  154.         _DEST Layer(62): LINE (0, 0)-(639, 399), _RGBA32(0, 0, 0, 0), BF
  155.         _DEST Layer(63): LINE (0, 0)-(639, 399), _RGBA32(0, 0, 0, 0), BF
  156.         _DEST _DISPLAY
  157.         MapDrawer 144, 24, Game.MapX, Game.MapY, Scaling, Plains, 62
  158.         DrawSprite 144, 24, Game.MapX, Game.MapY, Scaling, 63
  159.         _PUTIMAGE (0, 0)-(639, 399), Layer(62), _DISPLAY
  160.         '_DELAY 1
  161.         _CLEARCOLOR 0, Layer(63)
  162.         _PUTIMAGE (0, 0)-(639, 399), Layer(63), _DISPLAY
  163.         '_DELAY 1
  164.         _PUTIMAGE (0, 0)-(639, 399), Layer(Human), _DISPLAY
  165.         '_DELAY 1
  166.         IF INKEY$ = CHR$(27) THEN END
  167.         _DISPLAY
  168.     NEXT F%
  169.     'MapDrawer 144, 24, Game.MapX, Game.MapY, Scaling, Plains, _DISPLAY
  170.     'DrawSprite 144, 24, Game.MapX, Game.MapY, Scaling, _DISPLAY
  171.     _DELAY .1
  172.     'update units pos
  173.     Unit(0).Movement.MapX = Path(i%).x
  174.     Unit(0).Movement.MapY = Path(i%).y
  175. NEXT i%
  176.  
  177. '$include:'Movementdata.bi'
  178.  
  179. '$include:'Loadlayers.bi'
  180. '$include:'Warpath.bi'
  181. '$include:'MapDrawer.bi'
  182. '$include:'DrawSprite.bi'
  183.  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: CLEARCOLOR not working.
« Reply #7 on: September 01, 2018, 02:05:41 pm »
Maybe.... if is first set CLEARCOLOR but then is something drawed to this screen, is MAYBE then previous CLEARCOLOR not accepted? I donĀ“t know.

I test it and previous is not right. So -  next theorem is, that this is, because both use the same image. Its one image in memory. You use two pointers to one image. Maybe try it with two files - or better use copyimage and copy it, one clearcolor to one image, if it then help.
« Last Edit: September 01, 2018, 02:28:29 pm by Petr »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: CLEARCOLOR not working.(figured out)
« Reply #8 on: September 02, 2018, 08:51:37 pm »
drawing to the layer basically undoes the CLEARCOLOR effect and would have to be done again.
Perhaps we need a transparent option for putimage? kindof like DQBPUT had back in the day.
Granted after becoming radioactive I only have a half-life!

Offline ExilePrisoner

  • Newbie
  • Posts: 6
    • View Profile
Re: CLEARCOLOR not working.(figured out)
« Reply #9 on: September 02, 2018, 10:54:34 pm »
Gots these wokings

Code: QB64: [Select]
  1. DEFLNG A-Z
  2. TheScreen& = _NEWIMAGE(800, 600, 32)
  3.  
  4.  
  5. Layer1& = _LOADIMAGE("MyTile1.bmp", 32)
  6. Layer2& = _LOADIMAGE("MyPeasant1.bmp", 32)
  7. Layer3& = _LOADIMAGE("MyPeasant2.bmp", 32)
  8.  
  9.  
  10. SCREEN TheScreen&
  11. _PUTIMAGE , Layer1&, TheScreen&
  12.  
  13. _CLEARCOLOR _RGB32(0, 0, 0), Layer2&
  14. _PUTIMAGE , Layer2&, TheScreen&
  15.  
  16. _CLEARCOLOR _RGB32(224, 224, 224), Layer3&
  17. _PUTIMAGE , Layer3&, TheScreen&
  18.  
  19.  

This are correct nows?