Author Topic: Intro Video for my KingsBounty game.  (Read 2748 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
Intro Video for my KingsBounty game.
« on: February 25, 2019, 11:29:02 am »
 Finished the intro for my King's Bounty clone and since it seems a lot of people can't get audio working in QB64 I thought I'd capture it to a video, so its posted on youtube for everybody to check out. 

Let me Know: A-if the link works, B-what you think of how the Intro 'flows'

Here is the code,

Code: QB64: [Select]
  1. 'Kings Bounty 64, Logo Screen Intro
  2. '2019, Feb 25, 18:10 EST
  3. '2019, Feb 26, 00:32 EST Ver 1.1a
  4. 'UniKorn ProDucKions- Cobalt
  5. 'YouTube Preview-  [youtube]https://youtu.be/NJ6gJVpzGN8[/youtube]
  6. 'audio: "Dark Star" by Atom Music Audio
  7.  
  8. SCREEN _NEWIMAGE(640, 480, 32)
  9. CONST TRUE = -1, FALSE = NOT TRUE
  10. DIM SHARED Layer(24) AS LONG
  11. DIM SHARED RES_Size(64) AS LONG, RES_FOffset&(64)
  12. '-------------Logo Intro Screen needs------------
  13. CONST LARGE = 1, SMALL = 2, START_SCREENS = 2, TEMP_1 = 3, TEMP_2 = 4
  14. DIM SHARED Trigger(10) AS _BYTE, IntroBGM&
  15. '------------------------------------------------
  16. RES_Loader
  17.  
  18. Layer(0) = _DISPLAY
  19. Layer(1) = _NEWIMAGE(640, 480, 32) 'mix layer
  20. Layer(START_SCREENS) = LoadGFX&(RES_FOffset&(1), RES_Size(1)) '_LOADIMAGE("startscreens.bmp", 32) 'sheet layer
  21. Layer(TEMP_1) = _NEWIMAGE(640, 480, 32) 'fade in\out layer
  22. Layer(TEMP_2) = _NEWIMAGE(640, 480, 32) 'NWC screen fade
  23. _CLEARCOLOR _RGB32(0, 0, 0), Layer(START_SCREENS)
  24. IntroBGM& = LoadSFX&(RES_FOffset&(2), RES_Size(2)) '_SNDOPEN("LogoScreen002a.ogg")
  25. FOR i%% = 0 TO 10
  26.  Trigger(i%%) = FALSE
  27. NEXT i%%
  28. _TITLE "Kings Bounty 64- Logo Intro"
  29. IF IntroBGM& THEN _SNDPLAY IntroBGM&
  30.  
  31. Run_Logo_Intro
  32.  
  33. Fade_In_Character_Screen
  34.  
  35.  
  36. SUB Run_Logo_Intro
  37.  DO
  38.   Tick! = INT(_SNDGETPOS(IntroBGM&) * 1000) / 1000
  39.   IF Tick! >= .22 AND Trigger(0) = FALSE THEN Fade_In_UKP_Logo: Trigger(0) = TRUE
  40.   IF Tick! >= 6.14 AND Trigger(1) = FALSE THEN Fade_Out_UKP_Logo: Trigger(1) = TRUE
  41.   IF Tick! >= 10.65 AND Trigger(2) = FALSE THEN Fade_In_EA_Logo: Trigger(2) = TRUE
  42.   IF Tick! >= 16.46 AND Trigger(3) = FALSE THEN Fade_Out_EA_Logo: Trigger(3) = TRUE
  43.   IF Tick! >= 20.88 AND Trigger(4) = FALSE THEN Fade_In_NWC_Planet: Trigger(4) = TRUE
  44.   IF Tick! >= 26.81 AND Trigger(5) = FALSE THEN Drop_NWC_Sword: _PUTIMAGE , Layer(0), Layer(TEMP_1): Trigger(5) = TRUE
  45.   IF Tick! >= 28.83 AND Trigger(6) = FALSE THEN Raise_NWC_Logo: _PUTIMAGE , Layer(0), Layer(TEMP_1): Trigger(6) = TRUE
  46.   IF Tick! >= 32.1 AND Trigger(7) = FALSE THEN
  47.    IF NOT In_Sparkle%% THEN
  48.     IF INT(RND * 100) + 1 >= 91 THEN
  49.      x% = INT(RND * 560) + 28
  50.      y% = INT(RND * 48) + 208
  51.      IF INT(RND * 100) + 1 >= 51 THEN s% = LARGE ELSE s% = SMALL
  52.      In_Sparkle%% = 5
  53.     END IF
  54.    END IF
  55.    _PUTIMAGE , Layer(TEMP_1), Layer(1)
  56.    IF In_Sparkle%% THEN
  57.     Sparkle x%, y%, s%
  58.     In_Sparkle%% = In_Sparkle%% - 1
  59.    END IF
  60.    _PUTIMAGE , Layer(1), Layer(0)
  61.    IF In_Sparkle%% THEN _DELAY .1 ELSE _DELAY .025
  62.   END IF
  63.  
  64.   IF Tick! > 40.1 AND Trigger(8) = FALSE THEN
  65.    Trigger(7) = TRUE: Trigger(8) = TRUE
  66.    _PUTIMAGE , Layer(0), Layer(TEMP_2): ClearLayer 3
  67.    Fade_Out_NWC_Logo
  68.   END IF
  69.  
  70.   IF Tick! > 41.0 AND Trigger(9) = FALSE THEN Fade_In_KB_Title: Trigger(9) = TRUE
  71.   IF Tick! > 64.5 AND Trigger(10) = FALSE THEN Fade_Out_KB_Title: Trigger(10) = TRUE
  72.   _DELAY .001
  73.   LOCATE 1, 1: PRINT Tick!
  74.   IF INKEY$ = CHR$(27) THEN _SNDSTOP IntroBGM&
  75.  LOOP WHILE _SNDPLAYING(IntroBGM&)
  76.  
  77. SUB Fade_In_Character_Screen
  78.  FOR i%% = 0 TO 63 STEP 2
  79.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (0, 448)-STEP(319, 223)
  80.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  81.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  82.   _PUTIMAGE , Layer(1), Layer(0)
  83.   _DELAY .025
  84.  NEXT i%%
  85.  
  86. SUB Sparkle (X%, Y%, S%)
  87.  STATIC Sparkle_Frame%%, Count_up%%
  88.  'large sparkle
  89.  IF S% = LARGE THEN
  90.   _PUTIMAGE (X%, Y%), Layer(START_SCREENS), Layer(1), (136 - Sparkle_Frame%% * 26, 420)-STEP(26, 26)
  91.  ELSEIF S% = SMALL THEN
  92.   _PUTIMAGE (X%, Y%), Layer(START_SCREENS), Layer(1), (194 - Sparkle_Frame%% * 15, 433)-STEP(14, 14)
  93.  IF NOT Count_up%% THEN Sparkle_Frame%% = Sparkle_Frame%% + 1 ELSE Sparkle_Frame%% = Sparkle_Frame%% - 1
  94.  IF Sparkle_Frame%% = 2 THEN Count_up%% = TRUE
  95.  IF Sparkle_Frame%% = 0 THEN Count_up%% = FALSE
  96.  
  97. SUB Fade_In_UKP_Logo
  98.  FOR i%% = 0 TO 63 STEP 2
  99.   _PUTIMAGE (0, 0), Layer(START_SCREENS), Layer(1), (0, 672)-STEP(639, 479)
  100.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  101.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  102.   _PUTIMAGE , Layer(1), Layer(0)
  103.   _DELAY .025
  104.  NEXT i%%
  105.  
  106. SUB Fade_Out_UKP_Logo
  107.  FOR i%% = 63 TO 0 STEP -3
  108.   _PUTIMAGE (0, 0), Layer(START_SCREENS), Layer(1), (0, 672)-STEP(639, 479)
  109.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  110.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  111.   _PUTIMAGE , Layer(1), Layer(0)
  112.   _DELAY .05
  113.  NEXT i%%
  114.  
  115. SUB Fade_In_EA_Logo
  116.  FOR i%% = 0 TO 63 STEP 1
  117.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (0, 0)-STEP(319, 223)
  118.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  119.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  120.   _PUTIMAGE , Layer(1), Layer(0)
  121.   _DELAY .015
  122.  NEXT i%%
  123.  
  124. SUB Fade_Out_EA_Logo
  125.  FOR i%% = 63 TO 0 STEP -3
  126.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (0, 0)-STEP(319, 223)
  127.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  128.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  129.   _PUTIMAGE , Layer(1), Layer(0)
  130.   _DELAY .05
  131.  NEXT i%%
  132.  
  133. SUB Fade_In_NWC_Planet
  134.  FOR i%% = 0 TO 63 STEP 1
  135.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (320, 0)-STEP(319, 223)
  136.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  137.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  138.   _PUTIMAGE , Layer(1), Layer(0)
  139.   _DELAY .025
  140.  NEXT i%%
  141.  
  142. SUB Drop_NWC_Sword
  143.  _SETALPHA 255, , Layer(TEMP_1)
  144.  FOR i%% = 0 TO 54 STEP 1
  145.   _PUTIMAGE (376 - Xo%, -400 + Yo%)-STEP(141, 395), Layer(START_SCREENS), Layer(1), (0, 250)-STEP(70, 197)
  146.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (320, 0)-STEP(319, 223)
  147.   _PUTIMAGE , Layer(1), Layer(0)
  148.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  149.   _DELAY .004
  150.   Xo% = Xo% + 2
  151.   Yo% = Yo% + 8
  152.  NEXT i%%
  153.  
  154. SUB Raise_NWC_Logo
  155.  FOR i%% = 0 TO 66 STEP 1
  156.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  157.   _PUTIMAGE (31, 580 - Yo%)-STEP(260, 102), Layer(START_SCREENS), Layer(1), (104, 250)-STEP(130, 51)
  158.   _PUTIMAGE (294, 614 - Yo%)-STEP(321, 53), Layer(START_SCREENS), Layer(1), (104, 302)-STEP(161, 27)
  159.   _PUTIMAGE , Layer(1), Layer(0)
  160.   Yo% = Yo% + 6
  161.   _DELAY .04
  162.  NEXT i%%
  163.  
  164. SUB Fade_Out_NWC_Logo
  165.  FOR i%% = 63 TO 0 STEP -3
  166.   _PUTIMAGE , Layer(TEMP_2), Layer(1)
  167.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  168.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  169.   _PUTIMAGE , Layer(1), Layer(0)
  170.   _DELAY .001
  171.  NEXT i%%
  172.  
  173. SUB Fade_In_KB_Title
  174.  FOR i%% = 0 TO 63 STEP 1
  175.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (320, 224)-STEP(319, 223)
  176.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  177.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  178.   _PUTIMAGE , Layer(1), Layer(0)
  179.   _DELAY .06
  180.  NEXT i%%
  181.  
  182. SUB Fade_Out_KB_Title
  183.  FOR i%% = 63 TO 0 STEP -1
  184.   _PUTIMAGE (0, 16)-STEP(639, 447), Layer(START_SCREENS), Layer(1), (320, 224)-STEP(319, 223)
  185.   _SETALPHA 255 - i%% * 4, , Layer(TEMP_1)
  186.   _PUTIMAGE , Layer(TEMP_1), Layer(1)
  187.   _PUTIMAGE , Layer(1), Layer(0)
  188.   _DELAY .05
  189.  NEXT i%%
  190.  
  191. SUB ClearLayer (id%%)
  192.  old& = _DEST
  193.  _DEST Layer(id%%)
  194.  CLS
  195.  _DEST old&
  196.  
  197. SUB RES_Loader
  198.  '-------------layer loader-----------------------
  199.  OPEN "Intro.RES" FOR BINARY AS #1
  200.  GET #1, , c~%% 'number of records
  201.  FOR w% = 1 TO c~%%
  202.   GET #1, , RES_FOffset&(w%)
  203.   GET #1, , RES_Size(w%)
  204.   RES_FOffset&(w%) = RES_FOffset&(w%) + 1
  205.  '------------------------------------------------
  206.  
  207. FUNCTION LoadGFX& (Foff&, Size&)
  208.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  209.  OPEN "temp.dat" FOR BINARY AS #3
  210.  dat$ = SPACE$(Size&)
  211.  GET #1, Foff&, dat$
  212.  PUT #3, , dat$
  213.  CLOSE #3
  214.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  215.  
  216. FUNCTION LoadSFX& (Foff&, Size&)
  217.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  218.  OPEN "temp.dat" FOR BINARY AS #3
  219.  dat$ = SPACE$(Size&)
  220.  GET #1, Foff&, dat$
  221.  PUT #3, , dat$
  222.  CLOSE #3
  223.  LoadSFX& = _SNDOPEN("temp.dat")

Without the resource file it won't run so be sure to download it too, but you can see how I fade in and out, also how I tried to get the timing to work. odd thing is timing still shifts a little bit from machine to machine even though its based off the time of the audio file playing which shouldn't change from machine to machine.
« Last Edit: February 25, 2019, 02:11:15 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Intro Video for my KingsBounty game.
« Reply #1 on: February 25, 2019, 12:04:37 pm »
Nice! Good luck with bringing the project to life. I featured your into here: https://www.tapatalk.com/groups/qbasic/viewtopic.php?f=648955&t=39446

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Intro Video for my KingsBounty game.
« Reply #2 on: February 25, 2019, 02:11:39 pm »
Thanks Pete.
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: Intro Video for my KingsBounty game.
« Reply #3 on: February 26, 2019, 11:38:33 am »
I wrote my clear conclusion under the video. I like it very much.