Author Topic: (Solved)Why is POINT returning a different color value?  (Read 4131 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
(Solved)Why is POINT returning a different color value?
« on: November 01, 2018, 06:37:04 pm »
I haven't been able to isolate just what is causing this but POINT is returning a color with a value of :4278258432 but when I check the color by PRINT _RGB32(1,11,12) I get :4278258444 and the array that stores the colors ArmsID(1,11)=4278258444 and when I screen capture and use my graphics software the color returned is RGB:1,11,12 .
the detection of a non-black color is in the right spot so I don't think its reading the wrong location(and no location uses 4278258432 anyway)
Its almost as if POINT is losing the BLUE component.(1,11,0)
COLLISIONTARGET uses POINT to get the color
DESTROYTARGET is where the program stops and displays the COLLISION LAYER and the numbers of the POINT return and the _RGB32 value as well as the value held in the ArmsID() array where the target that was hit is.
A- to run the test, press 1 at the title screen
B-press right(to speed up getting to the dreadnaught continue to press right)
C- after some time the dreadnaught will apear(dont press up or down)
D-after some of the dreadnaught gets on screen PRESS SPACE to shot.
when the shot collides with the bottom front small gun the program will stop and display the information from above, the colored boxes might be hard to see cause the values are small

Code: QB64: [Select]
  1. 'The Dreadnaught Factor 64
  2. 'Clone 2018/10/29-13:10 Cobalt
  3. 'V0.1
  4. 'added title screen
  5. 'added startup data
  6. 'added player blaster shot
  7. '
  8. TYPE Dreadnaught
  9.  Xsize AS _BYTE 'ship size X
  10.  Ysize AS _BYTE 'ship size Y
  11.  Engines AS _BYTE 'Engines remaining 0-4
  12.  Vents AS _BYTE 'Vents remaining 0-16 (0 explodes ship)
  13.  Silos AS _BYTE 'Silos remaining 0-5
  14.  ShotsFired AS _BYTE
  15. TYPE Gamedata
  16.  Ships AS _BYTE 'Dreadnaughts destroied
  17.  Score AS _UNSIGNED LONG 'Players score
  18.  Lives AS _UNSIGNED _BYTE 'Player lives remaining
  19.  Distance AS _BYTE 'Dreadnaught Distance remaining
  20.  Level AS _BYTE '1-7
  21.  Shipcount AS _BYTE '1,1,2,5,10,15,100
  22. TYPE Playerdata
  23.  Xpos AS SINGLE
  24.  Ypos AS SINGLE
  25.  SpeedX AS SINGLE
  26.  SpeedY AS SINGLE
  27.  ShotsFired AS _BYTE
  28. TYPE Shotdata
  29.  Xpos AS SINGLE
  30.  Ypos AS SINGLE
  31.  Kind AS _BYTE
  32.  Time AS _BYTE
  33. TYPE StarData
  34.  Xpos AS SINGLE
  35.  Ypos AS SINGLE
  36. rem out '$include:'Dreadnaughts.txt'
  37. DIM SHARED Ship(44, 32, 1) AS _BYTE 'STRING * 2
  38. DIM SHARED Arms(44, 32, 1) AS _BYTE 'STRING * 2
  39. DIM SHARED ArmsID(44, 32) AS _UNSIGNED LONG ' color for target id box in collision layer
  40. DIM SHARED Layer(16) AS LONG, FFX(2) AS LONG, SFX(24) AS LONG
  41. DIM SHARED S AS Dreadnaught, G AS Gamedata, P AS Playerdata
  42. DIM SHARED PS(2) AS Shotdata, DS(10) AS Shotdata, Star(50) AS StarData
  43.  
  44. CONST TRUE = -1, FALSE = NOT TRUE, SPRITES = 0, MASK = 3, SHIP = 4, COLLISION = 8
  45. CONST EmptySpace = _RGB32(0, 0, 0)
  46. CONST Shot = 1, Bomb = 2, SGun = 3, LGun = 4, STorp = 5, LTorp = 6, Trakr = 7
  47. CONST max = 7, min = 1, Stars = 50
  48.  
  49. 'INIT---------------------------------------
  50. INITGame
  51. '+++++++++++++++++++++++++++++++++++++++++++
  52. TitleScreen
  53. ShipStartdata
  54. PlayerStartdata
  55. LaunchScreen
  56. '_SNDLOOP SFX(12)
  57. 'Start data
  58.  
  59. 'END
  60.  
  61. LoadDreadnaughtlayout
  62. DrawDreadNaughtBase SHIP
  63. FOR i% = 1 TO Stars
  64.  Star(i%).Xpos = INT(RND * 640)
  65.  Star(i%).Ypos = INT(RND * 470) + 5
  66. NEXT i%
  67.  
  68.  KBD& = _KEYHIT
  69.  SELECT CASE KBD&
  70.   CASE 13 'drop bomb
  71.   CASE 27
  72.    exitflag%% = TRUE
  73.  
  74.  Controls 'arrow key processes
  75.  
  76.  IF P.ShotsFired THEN ProcessPlayerShots
  77.  movestarfield
  78.  drawstarfield
  79.  
  80.  _PUTIMAGE , Layer(5), Layer(2)
  81.  _PUTIMAGE (P.Xpos, P.Ypos - 136), Layer(SHIP), Layer(2)
  82.  DrawDreadnaught P.Xpos, P.Ypos - 136, 2
  83.  _PUTIMAGE (64, 226), Layer(SPRITES), Layer(2), (0, 162)-(31, 175) 'player
  84.  DrawPlayerShot 2 'draw shots to layer 2
  85.  _PUTIMAGE , Layer(MASK), Layer(2)
  86.  _PUTIMAGE , Layer(2), Layer(1)
  87.  ClearLayer 2
  88.  _PRINTSTRING (0, 464), STR$(P.Ypos) + "  " + STR$(PS(1).Ypos)
  89.  _DELAY .01
  90.  
  91.  P.Xpos = P.Xpos - P.SpeedX
  92.  IF P.Xpos <= -920 THEN UpdateShipDistance: LaunchScreen
  93.  P.Ypos = P.Ypos + P.SpeedY
  94.  IF P.Ypos > 480 THEN P.Ypos = 480: P.SpeedY = 0
  95.  IF P.Ypos < -720 THEN P.Ypos = -720: P.SpeedY = 0
  96. LOOP UNTIL exitflag%%
  97. Delta:
  98. DATA 24,21
  99. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0T,0V,0F,0A,0A,0I
  100. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,0A
  101. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,0A,0A,0A
  102. data 00,00,00,00,00,00,00,00,00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,1T,1V,1V,1U,0A
  103. data 00,00,00,00,00,00,00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,1T,1F,1A,1A,1A,1A,0A
  104. data 00,00,00,00,00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,1T,1F,1A,1A,1A,1A,1A,1A,0A
  105. data 00,00,00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,1T,1F,1A,1A,1A,1A,2T,2V,2U,1A,0A
  106. data 00,00,00,00,00,0T,0F,0A,0A,0A,0A,0A,1T,1F,1A,1A,1A,1A,1A,1A,2A,2A,2A,1A,0A
  107. data 00,00,00,0T,0F,0A,0A,0A,0A,0A,1T,1F,1A,1A,1A,1A,1A,1A,2T,2F,2A,2A,2A,1A,0A
  108. data 00,0T,0F,0A,0A,0A,0A,0A,1T,1F,1A,1A,1A,1A,2T,2A,1A,1A,2A,2A,2A,3T,3A,1A,0A
  109. data 0B,0A,0A,0A,0A,0A,0A,1L,1A,1A,1A,1A,1A,2B,3L,3A,1A,1A,2A,2A,3L,3A,3A,1A,0A
  110. data 0C,0A,0A,0A,0A,0A,0A,1M,1A,1A,1A,1A,1A,2C,3M,3A,1A,1A,2A,2A,3M,3A,3A,1A,0A
  111. data 00,0J,0G,0A,0A,0A,0A,0A,1J,1G,1A,1A,1A,1A,2J,2A,1A,1A,2A,2A,2A,3J,3A,1A,0A
  112. data 00,00,00,0J,0G,0A,0A,0A,0A,0A,1J,1G,1A,1A,1A,1A,1A,1A,2J,2G,2A,2A,2A,1A,0A
  113. data 00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,1J,1G,1A,1A,1A,1A,1A,1A,2A,2A,2A,1A,0A
  114. data 00,00,00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,1J,1G,1A,1A,1A,1A,2J,2W,2K,1A,0A
  115. data 00,00,00,00,00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,1J,1G,1A,1A,1A,1A,1A,1A,0A
  116. data 00,00,00,00,00,00,00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,1J,1G,1A,1A,1A,1A,0A
  117. data 00,00,00,00,00,00,00,00,00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,1J,1W,1W,1K,0A
  118. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,0A,0A,0A
  119. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0J,0G,0A,0A,0A,0A,0A,0A
  120. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0J,0W,0G,0A,0A,0H
  121.  
  122. DeltaWepondry:
  123. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  124. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2G,00,00,0E,0F,00
  125. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2A,00,00,00,00,1E,1F,00
  126. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2E,00,00,0I,0J,00,00,00,00,00
  127. data 00,00,00,00,00,00,00,00,00,00,00,00,00,2A,00,00,0I,0J,00,00,00,0E,0F,00,0A
  128. data 00,00,00,00,00,00,00,00,00,00,00,2G,00,00,0I,0J,00,00,2A,00,00,1E,1F,00,1A
  129. data 00,00,00,00,00,00,00,00,00,2A,00,00,0I,0J,00,00,0E,0F,00,00,00,00,00,00,00
  130. data 00,00,00,00,00,00,00,2E,00,00,0I,0J,00,00,00,00,1E,1F,00,00,2A,00,0M,00,00
  131. data 00,00,00,00,00,2A,00,00,0I,0J,00,00,00,00,2A,00,00,00,00,00,2A,00,1M,00,0A
  132. data 00,00,00,2A,00,00,0I,0J,00,00,00,2A,00,00,00,2C,00,0M,2A,0I,0J,00,2C,00,1A
  133. data 00,2A,00,0E,0F,00,0M,00,2A,00,0E,0F,00,00,00,0C,00,1M,2A,00,00,00,0C,00,00
  134. data 00,2A,00,1E,1F,00,1M,00,2A,00,1E,1F,00,00,00,1C,00,0M,2A,00,00,00,1C,00,00
  135. data 00,00,00,2A,00,00,0I,0J,00,00,00,2A,00,00,00,2C,00,1M,2A,0I,0J,00,2C,00,0A
  136. data 00,00,00,00,00,2A,00,00,0I,0J,00,00,00,00,2A,00,00,00,00,00,2A,00,0M,00,1A
  137. data 00,00,00,00,00,00,00,2E,00,00,0I,0J,00,00,00,00,0E,0F,00,00,2A,00,1M,00,00
  138. data 00,00,00,00,00,00,00,00,00,2A,00,00,0I,0J,00,00,1E,1F,00,00,00,00,00,00,00
  139. data 00,00,00,00,00,00,00,00,00,00,00,2G,00,00,0I,0J,00,00,2A,00,00,0E,0F,00,0A
  140. data 00,00,00,00,00,00,00,00,00,00,00,00,00,2A,00,00,0I,0J,00,00,00,1E,1F,00,1A
  141. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2E,00,00,0I,0J,00,00,00,00,00
  142. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2A,00,00,00,00,0E,0F,00
  143. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2G,00,00,1E,1F,00
  144. data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  145.  
  146.  
  147.  
  148. SUB ClearLayer (id%%)
  149.  old& = _DEST
  150.  _DEST Layer(id%%)
  151.  CLS
  152.  _DEST old&
  153.  
  154. FUNCTION CollisionTarget (id%%)
  155.  _SOURCE Layer(COLLISION)
  156.  test~& = POINT(PS(id%%).Xpos, PS(id%%).Ypos)
  157.  _SOURCE Layer(1)
  158.  IF test~& <> EmptySpace THEN Result~& = test~& ELSE Result~& = FALSE
  159.  CollisionTarget = Result~&
  160.  
  161. SUB Controls
  162.  STATIC SlowFlag%%, CoastFlag%%, ShotLock%%
  163.  
  164.  IF _KEYDOWN(18432) THEN P.SpeedY = P.SpeedY + .25: CoastFlag%% = FALSE
  165.  IF P.SpeedY >= 4 THEN P.SpeedY = 4
  166.  
  167.  IF _KEYDOWN(19200) THEN P.SpeedX = P.SpeedX - .25: IF P.SpeedX > 1 THEN SlowFlag%% = FALSE
  168.  IF P.SpeedX < .5 THEN P.SpeedX = .5
  169.  IF _KEYDOWN(19712) THEN P.SpeedX = P.SpeedX + .25: SlowFlag%% = FALSE
  170.  IF P.SpeedX > max THEN P.SpeedX = max
  171.  
  172.  IF _KEYDOWN(20480) THEN P.SpeedY = P.SpeedY - .25: CoastFlag%% = FALSE
  173.  IF P.SpeedY <= -4 THEN P.SpeedY = -4
  174.  
  175.  IF NOT SlowFlag%% THEN
  176.   IF NOT _KEYDOWN(19712) THEN
  177.    P.SpeedX = P.SpeedX - .05: IF P.SpeedX < min THEN P.SpeedX = min: SlowFlag%% = TRUE
  178.   END IF
  179.  
  180.  IF NOT CoastFlag%% THEN 'allow coast up and down
  181.   IF NOT _KEYDOWN(18432) AND NOT _KEYDOWN(20480) THEN
  182.    IF P.SpeedY > 0 THEN
  183.     P.SpeedY = P.SpeedY - .05
  184.     IF P.SpeedY <= .2 THEN CoastFlag%% = TRUE: P.SpeedY = 0
  185.    ELSE
  186.     P.SpeedY = P.SpeedY + .05
  187.     IF P.SpeedY >= -.2 THEN CoastFlag%% = TRUE: P.SpeedY = 0
  188.    END IF
  189.   END IF
  190.  
  191.   IF NOT ShotLock%% THEN
  192.    'shoot blaster
  193.    ShotLock%% = TRUE 'must release key to shoot again
  194.    P.ShotsFired = P.ShotsFired + 1
  195.    IF P.ShotsFired < 3 THEN MakeShot P.ShotsFired, Shot ELSE P.ShotsFired = 2
  196.   END IF
  197.   ShotLock%% = FALSE
  198.  
  199. SUB DestroyTarget (ID~&)
  200.  PRINT ID~&
  201. ' IF _FILEEXISTS("shotdebug.txt") THEN KILL "shotdebug.txt"
  202. ' OPEN "shotdebug.txt" FOR OUTPUT AS #2
  203. ' PRINT #2, ID~&
  204. ' PRINT #2, "---------------------"; S.Xsize * S.Ysize
  205.  FOR y% = 0 TO S.Ysize
  206.   FOR x% = 0 TO S.Xsize
  207.    IF ArmsID(x%, y%) <> 0 THEN PRINT #2, ArmsID(x%, y%); x%; y%
  208.    IF ArmsID(x%, y%) = ID~& THEN
  209.     PRINT x%, y%; ArmsID(x%, y%), Arms(x%, y%, 1)
  210.     ArmsID(x%, y%) = EmptySpace
  211.     Arms(x%, y%, 1) = Arms(x%, y%, 1) + 1
  212.     PRINT x%, y%; ArmsID(x%, y%), Arms(x%, y%, 1)
  213.     END
  214.    END IF
  215.   NEXT
  216. ' CLOSE
  217.  _PUTIMAGE (0, 0), Layer(COLLISION), _DISPLAY
  218.  PRINT ID~&, _RGB32(1, 11, 12), ArmsID(1, 11)
  219.  PRINT _RED32(ArmsID(1, 11)); _GREEN32(ArmsID(1, 11)); _BLUE32(ArmsID(1, 11))
  220.  PRINT _RED32(ID~&); _GREEN32(ID~&); _BLUE32(ID~&)
  221.  
  222. SUB DrawDreadnaught (Xloc%, Yloc%, LayerID%%)
  223.  'find last tile to display
  224.  Endx%% = (640 - Xloc%) / 32
  225.  Endy%% = (400 - Yloc%) / 32
  226.  'range check keep values within array size(or dreadnaught data size)
  227.  IF Endx%% > S.Xsize THEN Endx%% = S.Xsize
  228.  IF Endy%% > S.Ysize THEN Endy%% = S.Ysize
  229.  'find first tile to display
  230.  Startx%% = (0 + Xloc%) / 32
  231.  Starty%% = (0 + Yloc%) / 32
  232.  'make sure value is always negative(-) otherwise start at 0
  233.  IF Startx%% > 0 THEN Startx%% = 0
  234.  IF Starty%% > 0 THEN Starty%% = 0
  235.  'fix negative value to positive, this means that portion is off screen so
  236.  'start at the + array location in other words don't bother with whats off
  237.  'screen
  238.  Startx%% = ABS(Startx%%)
  239.  Starty%% = ABS(Starty%%)
  240.  ClearLayer COLLISION
  241.  FOR y% = Starty%% TO Endy%%
  242.   FOR x% = Startx%% TO Endx%%
  243.    layer% = Arms(x%, y%, 0) + 4
  244.    SELECT CASE Arms(x%, y%, 1)
  245.     CASE 0
  246.     CASE 65 TO 92
  247.      xoff% = 32 * (Arms(x%, y%, 1) - 65)
  248.      XL% = Xloc% + x% * 32
  249.      YL% = Yloc% + y% * 32
  250.      'draw ship targets(guns\vents\ect)
  251.      _PUTIMAGE (XL%, YL%), Layer(SPRITES), Layer(LayerID%%), (0 + xoff%, 64 + ((layer% - 4) * 32))-(31 + xoff%, 95 + ((layer% - 4) * 32))
  252.      'make collision layer(colored boxes for collision detections)
  253.      _DEST Layer(COLLISION)
  254.      LINE (XL%, YL%)-STEP(32, 32), ArmsID(x%, y%), BF
  255.      _DEST Layer(1) 'restore to _display layer
  256.    END SELECT
  257.   NEXT x%
  258.  NEXT y%
  259.  
  260. SUB DrawDreadNaughtBase (LayerID%%)
  261.  FOR y% = 0 TO S.Ysize
  262.   FOR x% = 0 TO S.Xsize
  263.    layer% = Ship(x%, y%, 0)
  264.    SELECT CASE Ship(x%, y%, 1)
  265.     CASE 0
  266.     CASE 65 TO 92
  267.      xoff% = 16 * (Ship(x%, y%, 1) - 65)
  268.      XL% = Xloc% + x% * 32
  269.      YL% = Yloc% + y% * 32
  270.      IF layer% > 0 THEN _PUTIMAGE (XL%, YL%)-(XL% + 32, YL% + 32), Layer(SPRITES), Layer(LayerID%%), (0, 0 + ((layer% - 1) * 16))-(15, 15 + ((layer% - 1) * 16))
  271.      _PUTIMAGE (XL%, YL%)-(XL% + 32, YL% + 32), Layer(SPRITES), Layer(LayerID%%), (0 + xoff%, 0 + (layer% * 16))-(15 + xoff%, 15 + (layer% * 16))
  272.    END SELECT
  273.   NEXT x%
  274.  NEXT y%
  275.  
  276. SUB DrawPlayerShot (tag%%)
  277.  FOR i%% = 1 TO P.ShotsFired
  278.   SELECT CASE PS(i%%).Time
  279.    CASE 0 TO 3
  280.     _PUTIMAGE (PS(i%%).Xpos, PS(i%%).Ypos), Layer(sprite), Layer(tag%%), (98, 186)-(107, 199)
  281.    CASE 4 TO 8
  282.     _PUTIMAGE (PS(i%%).Xpos, PS(i%%).Ypos), Layer(sprite), Layer(tag%%), (108, 186)-(117, 199)
  283.    CASE ELSE
  284.     _PUTIMAGE (PS(i%%).Xpos, PS(i%%).Ypos), Layer(sprite), Layer(tag%%), (119, 186)-(146, 199)
  285.  NEXT i%%
  286.  
  287. SUB drawstarfield
  288.  old& = _DEST
  289.  _DEST Layer(5)
  290.  CLS
  291.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(5)
  292.  FOR i% = 1 TO Stars
  293.   LINE (Star(i%).Xpos, Star(i%).Ypos)-STEP(2, 2), Star(i%).Colr, BF
  294.  NEXT i%
  295.  _DEST old&
  296.  
  297. SUB EraseShot (id%%)
  298.  PS(id%%).Xpos = 0
  299.  PS(id%%).Ypos = 0
  300.  PS(id%%).Time = 0
  301.  PS(id%%).Kind = 0
  302.  
  303. SUB INITGame
  304.  SCREEN _NEWIMAGE(640, 480, 32)
  305.  Layer(0) = _LOADIMAGE("DFsprit64.PNG") '  Sprite Layer
  306.  Layer(1) = _DISPLAY
  307.  Layer(2) = _NEWIMAGE(640, 480, 32) 'Armorment draw layer
  308.  Layer(3) = _NEWIMAGE(640, 480, 32) 'screen mask, top 32 and bottom 80 pixels masked
  309.  Layer(4) = _NEWIMAGE(1408, 1024, 32) 'Ship base layer
  310.  Layer(5) = _NEWIMAGE(640, 480, 32) 'Star Field
  311.  Layer(6) = _LOADIMAGE("LaunchScreen.bmp", 32)
  312.  Layer(7) = _LOADIMAGE("titlescreen.bmp", 32)
  313.  Layer(8) = _NEWIMAGE(640, 480, 32) 'Dreadnaught weapon collision box layer
  314.  _PUTIMAGE (0, 0), Layer(7), Layer(1)
  315.  LINE (0, 400)-(639, 479), POINT(1, 1), BF
  316.  
  317.  'DIM Size(64) AS LONG, FOffset&(64)
  318. ' OPEN "dreadnaughtfactor.SFX" FOR BINARY AS #1
  319. ' GET #1, , c%%
  320. ' FOR w% = 1 TO c%%
  321. '  GET #1, , foffset&
  322. '  GET #1, , Size(w%)
  323. ' NEXT
  324. ' FOR w% = 1 TO c%%
  325. '  OPEN "temp.dat" FOR BINARY AS #3
  326. '  dat$ = SPACE$(Size(w%))
  327. '  GET #1, , dat$
  328. '  PUT #3, , dat$
  329. '  CLOSE #3
  330. '  SFX(w%) = _SNDOPEN("temp.dat")
  331. '  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  332. ' NEXT w%
  333. ' CLOSE
  334.  
  335.  _DEST Layer(MASK)
  336.  LINE (0, 0)-(639, 479), _RGB32(0, 0, 0), BF
  337.  LINE (0, 33)-(639, 400), _RGB32(1, 1, 1), BF
  338.  LINE (0, 464)-(639, 479), _RGB32(1, 1, 1), BF
  339.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(SPRITES)
  340.  _CLEARCOLOR _RGB32(1, 1, 1), Layer(MASK)
  341.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(SHIP)
  342.  FFX(1) = _LOADFONT("PixelIntv.otf", 40, "monospace")
  343.  IF FFX(1) THEN _FONT FFX(1)
  344.  
  345. SUB LaunchScreen
  346.  _FONT FFX(1)
  347.  _PUTIMAGE (0, 32), Layer(6), Layer(1)
  348.  LINE (352, 99)-STEP(32, 32), _RGB32(0, 0, 0), BF 'erase old numbers
  349.  LINE (544, 99)-STEP(32, 32), _RGB32(0, 0, 0), BF
  350.  LINE (512, 323)-STEP(64, 32), _RGB32(0, 0, 0), BF
  351.  'change gate color based on level
  352.  IF G.Level > 1 THEN
  353.   _PUTIMAGE (400, 222), Layer(SPRITES), Layer(1), (256, 96 + ((G.Level - 2) * 12))-(287, 107 + ((G.Level - 2) * 12))
  354.   _PUTIMAGE (400, 217)-STEP(31, -11), Layer(SPRITES), Layer(1), (256, 96 + ((G.Level - 2) * 12))-(287, 107 + ((G.Level - 2) * 12))
  355.  v1$ = LTRIM$(STR$(G.Score)) 'create strings for printing
  356.  v2$ = LTRIM$(STR$(G.Ships))
  357.  v3$ = LTRIM$(STR$(G.Distance))
  358.  COLOR _RGB32(252, 224, 24) 'change color
  359.  _PRINTSTRING (384 - (LEN(v1$) * _FONTWIDTH(FFX(1))), 99), v1$, Layer(1) 'score
  360.  _PRINTSTRING (576 - (LEN(v2$) * _FONTWIDTH(FFX(1))), 99), v2$, Layer(1) 'Dreadnaughts destroyed
  361.  _PRINTSTRING (576 - (LEN(v3$) * _FONTWIDTH(FFX(1))), 323), v3$, Layer(1) 'Dreadnaughts distance
  362.  ic%% = G.Lives
  363.  IF ic%% > 15 THEN ic%% = 15 'only display upto 15 extra ships
  364.  FOR i%% = 0 TO ic%%
  365.   LINE (264, 230 + yy%%)-STEP(7, 3), _RGB32(0, 0, 255), BF
  366.   yy%% = yy%% + 8
  367.  NEXT i%%
  368.  'display Dreadnaught
  369.  _PUTIMAGE (418 + (G.Distance * 2), 206)-STEP(31, 27), Layer(SPRITES), Layer(1), (32, 161)-STEP(15, 13)
  370.  
  371.  FOR i%% = 0 TO 71 'move next hyperfighter to gate
  372.   IF ((i%% / 10) MOD 2) = 0 THEN
  373.    LINE (264 + xx~%%, 218)-STEP(7, 3), _RGB32(255, 255, 0), BF
  374.   ELSE
  375.    LINE (264 + xx~%%, 218)-STEP(7, 3), _RGB32(32, 32, 0), BF
  376.   END IF
  377.   _DELAY .025
  378.   LINE (264 + xx~%%, 218)-STEP(7, 3), _RGB32(0, 0, 0), BF
  379.   xx~%% = xx~%% + 2
  380.  NEXT i%%
  381.  i%% = 0
  382.  DO
  383.   IF ((i%% / 10) MOD 2) = 0 THEN
  384.    LINE (264 + xx~%%, 218)-STEP(7, 3), _RGB32(255, 255, 0), BF
  385.   ELSE
  386.    LINE (264 + xx~%%, 218)-STEP(7, 3), _RGB32(32, 32, 0), BF
  387.   END IF
  388.   _DELAY .025
  389.   i%% = i%% + 1: IF i%% = 100 THEN i%% = 0
  390.  LOOP UNTIL INKEY$ <> ""
  391.  '_SNDSTOP SFX(12)
  392.  '_SNDPLAY SFX(15)
  393.  COLOR _RGB32(255, 255, 255)
  394.  _FONT 16
  395.  
  396. SUB LoadDreadnaughtlayout
  397.  RESTORE Delta
  398.  READ S.Xsize
  399.  READ S.Ysize
  400.  DIM temp AS STRING * 2
  401.  
  402.  FOR y% = 0 TO S.Ysize
  403.   FOR x% = 0 TO S.Xsize
  404.    READ temp
  405.    Ship(x%, y%, 0) = VAL(LEFT$(temp, 1))
  406.    Ship(x%, y%, 1) = ASC(RIGHT$(temp, 1))
  407.  NEXT x%, y%
  408.  RESTORE DeltaWepondry
  409.  FOR y% = 0 TO S.Ysize
  410.   FOR x% = 0 TO S.Xsize
  411.    READ temp
  412.    Arms(x%, y%, 0) = VAL(LEFT$(temp, 1))
  413.    Arms(x%, y%, 1) = ASC(RIGHT$(temp, 1))
  414.    IF ASC(RIGHT$(temp, 1)) > 64 THEN ArmsID(x%, y%) = _RGB32(x%, y%, x% + y%) ELSE ArmsID(x%, y%) = 0
  415.  NEXT x%, y%
  416.  
  417. SUB MakeShot (id%%, tag%%)
  418.  PS(id%%).Xpos = 85
  419.  PS(id%%).Ypos = 226
  420.  PS(id%%).Time = 0
  421.  PS(id%%).Kind = tag%%
  422.  
  423. SUB movestarfield
  424.  FOR i% = 1 TO Stars
  425.   Star(i%).Xpos = Star(i%).Xpos - P.SpeedX
  426.   IF Star(i%).Xpos <= -1 THEN newstar i%, 1
  427.   Star(i%).Ypos = Star(i%).Ypos + P.SpeedY
  428.   IF Star(i%).Ypos <= -1 THEN newstar i%, 3
  429.   IF Star(i%).Ypos >= 480 THEN newstar i%, 2
  430.  NEXT i%
  431.  
  432. SUB newstar (num%, dir%)
  433.  SELECT CASE dir%
  434.   CASE 1
  435.    Star(num%).Xpos = 640
  436.    Star(num%).Ypos = INT(RND * 470) + 5
  437.    Star(num%).Colr = INT(RND * 240) + 15
  438.    Star(num%).Colr = _RGB32(Star(num%).Colr, Star(num%).Colr, Star(num%).Colr)
  439.   CASE 2
  440.    Star(num%).Xpos = Star(num%).Xpos
  441.    Star(num%).Ypos = 0
  442.   CASE 3
  443.    Star(num%).Xpos = Star(num%).Xpos
  444.    Star(num%).Ypos = 479
  445.  
  446. SUB PlayerStartdata
  447.  G.Lives = 10
  448.  G.Score = 0
  449.  G.Ships = 0
  450.  P.Xpos = (G.Distance * 30) ' distance from gate to ship
  451.  P.Ypos = 0
  452.  
  453.  
  454. SUB ProcessPlayerShots
  455.  FOR i%% = 1 TO P.ShotsFired
  456.   SELECT CASE PS(i%%).Kind
  457.    CASE Shot
  458.     PS(i%%).Xpos = PS(i%%).Xpos + P.SpeedX + 7
  459.     PS(i%%).Time = PS(i%%).Time + 1
  460.     PS(i%%).Ypos = PS(i%%).Ypos + P.SpeedY
  461.     HIT~& = CollisionTarget(i%%) 'check if shot hit a target
  462.     IF HIT~& OR PS(i%%).Time > 100 OR PS(i%%).Ypos < 26 OR PS(i%%).Ypos > 410 OR PS(i%%).Xpos > 630 THEN
  463.      IF i%% = 2 THEN P.ShotsFired = P.ShotsFired - 1: EraseShot 2
  464.      IF i%% = 1 AND P.ShotsFired = 2 THEN
  465.       SWAP PS(1), PS(2): P.ShotsFired = P.ShotsFired - 1: EraseShot 2
  466.      ELSE
  467.       P.ShotsFired = 0
  468.       EraseShot 1
  469.      END IF
  470.      IF HIT~& THEN DestroyTarget HIT~&: HIT~& = 0
  471.     END IF
  472.  
  473.    CASE Bomb
  474.  NEXT i%%
  475.  
  476. SUB ShipStartdata
  477.  S.Vents = 16
  478.  S.Engines = 4
  479.  S.Silos = 5
  480.  G.Distance = 93 - (G.Level - 1)
  481.  
  482. SUB TitleScreen
  483.  COLOR _RGB32(255, 255, 255), POINT(1, 1)
  484.  _PRINTSTRING (32, 384), "UniKorn ProDucKions"
  485.  _PRINTSTRING (32, 416), "Clone 2018 @ Cobalt"
  486.  COLOR _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  487.  DO
  488.   KBD$ = INKEY$
  489.   IF KBD$ <> "" AND KBD$ >= CHR$(49) AND KBD$ <= CHR$(55) THEN G.Level = VAL(KBD$): exitflag%% = TRUE
  490.   _DELAY .01
  491.  LOOP UNTIL exitflag%%
  492.  exitflag%% = FALSE
  493.  CLS
  494.  
  495. SUB UpdateShipDistance
  496.  G.Distance = G.Distance - (G.Level + (2 * S.Engines))
  497.  P.Xpos = G.Distance * 30
  498.  

you'll just need the image below for the spirtes, I believe thats it, sometimes its hard to keep track of what all is needed in these developmental stages. if it says something is missing let me know.

11/1/2018-17:02  updated the code to use the PNG version of the sprite sheet.
« Last Edit: November 01, 2018, 09:38:12 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Why is POINT returning a different color value?
« Reply #1 on: November 01, 2018, 07:34:12 pm »
This may be a case of PRINT using SINGLE values, which *can* lose blue values just as you describe.

I'm not at the PC right at this moment, but store the value in a temp variable and then print it and see how the numbers compare.

temp~& = _RGB(red,green,blue)
PRINT temp&
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Why is POINT returning a different color value?
« Reply #2 on: November 01, 2018, 08:51:38 pm »
Hi Cobalt
it seems you last out these file images to let work your code
Quote
Layer(6) = _LOADIMAGE("LaunchScreen.bmp", 32)
 Layer(7) = _LOADIMAGE("titlescreen.bmp", 32)
Programming isn't difficult, only it's  consuming time and coffee

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Why is POINT returning a different color value?
« Reply #3 on: November 01, 2018, 09:01:42 pm »
Hi Cobalt
it seems you last out these file images to let work your code
Quote
Layer(6) = _LOADIMAGE("LaunchScreen.bmp", 32)
 Layer(7) = _LOADIMAGE("titlescreen.bmp", 32)
Thanks TempB,

Knew I was forgetting something... and realized the sprite sheet upload is PNG, you'll need to change the loadimage line for that but I'll update that in the source above.
« Last Edit: November 01, 2018, 09:07:37 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Why is POINT returning a different color value?
« Reply #4 on: November 01, 2018, 09:27:48 pm »
This may be a case of PRINT using SINGLE values, which *can* lose blue values just as you describe.
I'm not at the PC right at this moment, but store the value in a temp variable and then print it and see how the numbers compare.
temp~& = _RGB(red,green,blue)
PRINT temp&

A function returns the POINT value through a ~& but now that I think about it what value do Functions default as? if I FunctionName = result~& does that make the function return a ~& or is it returning a single?
Do I need to explicitly define the function as a ~&? like  Function itsname~&(args...) ?
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
(solved)Why is POINT returning a different color value?
« Reply #5 on: November 01, 2018, 09:37:46 pm »
AH, so that seems to be it, Good thing you said something Steve. I never would have thought about the function return value otherwise and spent hours scratching my head.
Changing Function CollisionTarget (ID~&) to Function CollisionTarget~& (ID~&) fixed it.
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Why is POINT returning a different color value?
« Reply #6 on: November 01, 2018, 09:51:21 pm »
what value do Functions default as?

No type symbol at the end of a function name has it default to SINGLE, like any other variable, unless DEF statements (or _DEFINE) come into play.

You don't need the type symbol when you call the function though:
Code: QB64: [Select]
  1.  
  2.     a~& = _RGB32(255, 255, 255)
« Last Edit: November 01, 2018, 09:55:47 pm by FellippeHeitor »

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: (Solved)Why is POINT returning a different color value?
« Reply #7 on: November 01, 2018, 10:16:25 pm »
Awesome! You are recreating Activision games.
In order to understand recursion, one must first understand recursion.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Why is POINT returning a different color value?
« Reply #8 on: November 01, 2018, 10:53:10 pm »

You don't need the type symbol when you call the function though:

ah that is probably what made me think that because I gave it a ~& as the return value it would be the same. Good to know
Thanks Fellippe.

Awesome! You are recreating Activision games.


I am a fan of Intellivision games and big fan of the ones developed by Tom Loughry. (Dreadnaught factor, and AD&D Treasure of Tarmin being two in particular)
Granted after becoming radioactive I only have a half-life!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: (Solved)Why is POINT returning a different color value?
« Reply #9 on: November 04, 2018, 06:54:55 am »
Good stuff recreating old games...
android has a big hunger for these...

Who does know about Apple Market and Windows Market app?
Programming isn't difficult, only it's  consuming time and coffee