Author Topic: Unseen GDK - Dev Thread  (Read 8476 times)

0 Members and 1 Guest are viewing this topic.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Unseen GDK - Dev Thread
« on: June 18, 2018, 06:35:17 pm »
Hi Gang

I aint got much time right now but heres the latest version of GDK. Save it as UnseenGDK.bm in your QB64 folder.

Im hoping that you lot will help me in updating it to use QB64's newer commands.

Thanks

Unseen
« Last Edit: June 18, 2018, 06:38:49 pm by Unseen Machine »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #1 on: June 19, 2018, 04:06:43 am »
Hi UnseenMachine!
Haven't seen you for a long. Some samples demos will be good to understand your GDK.
Also, you can use QB64's inbuilt _D2R() and _R2D() to convert degrees to radians and vice versa, instead of having
your own GDK_RadianToDegree!() and GDK_DegreeTo Radian!().
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #2 on: June 19, 2018, 09:40:46 am »
Yes you could add _PI() to list too but that is a very rich set of sprite procedures.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #3 on: June 21, 2018, 09:08:02 pm »
Ashish - when i get a chance ill run a speed check and if the inbuilt commands are faster then ill happily update! Thanks for the suggestion and as for demos, well thats a good point... Ill build a basic game in stages to show how commands are used

Code: QB64: [Select]
  1. '// UnseenGDK Tutorials - No 1 : Generic Base Code
  2. '// For version 1.5 and up
  3. '// By John Onyon a.k.a Unseen Machine
  4.  
  5.  
  6. '// Create a screen for the program
  7. GDK_Screen_SetRes MainScreen&, 1024, 768
  8.  
  9. '// Define arrays for input handling
  10. DIM KB(1) AS KeyBoardState, Mouse(1) AS MouseState
  11.  
  12.  
  13. '// Main code
  14.   _LIMIT 30
  15.   CLS
  16.  
  17.   '// GET INPUT
  18.   GDK_Keyboard_GetState KB(0)
  19.   GDK_Mouse_GetState Mouse(0)
  20.  
  21.  
  22.   '// LOGIC
  23.  
  24.  
  25.   '// DRAWING
  26.  
  27.  
  28.  
  29.   '// Store input state's for comparisons next loop
  30.   KB(1) = KB(0)
  31.   Mouse(1) = Mouse(0)
  32.  
  33. '// END of Main code
  34.  
  35.  
  36. '// Library inclusions
  37. REM $INCLUDE:'UnseenGDK.bm'
  38.  
  39.  

Thats base code for almost every GDK program...GDK_GL is a bit more indepth!!!

@bplus - _PI! Well i've had to update VQB to use that over my pre built function so GDK should also follow suit! Nice suggestion, will be implemented and thanks for the kudos!

Unseen

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #4 on: June 21, 2018, 10:28:10 pm »
Regarding r2d and d2r conversions, I will bet cash money that constants are the fastest ie myDegreeAngle = radian_angle * const180slashPI, you skip function calls altogether and Constants are maybe as fast as Integer Variables for math.
« Last Edit: June 21, 2018, 10:30:40 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #5 on: June 21, 2018, 11:06:13 pm »
Code: QB64: [Select]
  1. _TITLE "const versus func r2d time.bas"
  2. 'QB64 v1.1 1106 started by bplus 2018-06-21
  3. x## = (180 / _ACOS(-1))
  4. PRINT x##
  5. CONST r2d = 57.29577951308232
  6. PRINT r2d - 180 / _ACOS(-1) 'not bad?
  7. PRINT 180 / _PI - r2d 'compare to built-in
  8. PRINT 180 / _PI - x## '10x worse!
  9. FOR i = 1 TO 1 'test  model , looks like exactly same results
  10.     FOR a = 0 TO _PI(2) STEP _PI(1 / 6)
  11.         da## = a * r2d
  12.         PRINT da##, _R2D(a)
  13.     NEXT
  14.  
  15. start! = TIMER
  16. FOR i = 1 TO 10000000
  17.     FOR a = 0 TO _PI(2) STEP _PI(1 / 6)
  18.         da## = _R2D(a)
  19.         'PRINT da##, _R2D(a)
  20.     NEXT
  21. funtime! = TIMER - start!
  22. PRINT "Time with function was:"; funtime!
  23.  
  24. start! = TIMER
  25. FOR i = 1 TO 10000000
  26.     FOR a = 0 TO _PI(2) STEP _PI(1 / 6)
  27.         da## = a * r2d
  28.         'PRINT da##, _R2D(a)
  29.     NEXT
  30. ctime! = TIMER - start!
  31. PRINT "Time with constant was:"; ctime
  32.  

Did I save anybody time testing?

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #6 on: June 22, 2018, 07:01:26 pm »
Bplus - First, thanks...nice to see some feedback, its appreciated

Second - I've never used constants in GDK as it would require a separate .bi library which is something ive always tried to avoid but im happy to remove the functions entirely and use the inbuilt ones, on checking GDK it appears i only call the function once in the whole library!

Path movement demo
Code: QB64: [Select]
  1. '// UnseenGDK Demo - Path Movement using absolute screen co-ordinates
  2.  
  3. '// Create Screen
  4. GDK_Screen_SetRes Main&, 800, 800
  5.  
  6. '// DIMension arrays for path points (X, Y, Speed)
  7. DIM Path AS Path, PathPoints(7) AS PathPoint
  8.  
  9. '// Load path points
  10. '// SUB GDK_Path_New (Path AS Path, PathPoint() AS PathPoint, NumPoints%, Reverse%, Repeat%, Relative%)
  11. GDK_Path_New Path, PathPoints(), 8, 1, 0, 0
  12.  
  13. '// Main loop
  14.     _LIMIT 30
  15.     CLS
  16.  
  17.     '// Update path
  18.     GDK_Path_Update Path, PathPoints()
  19.  
  20.     '// Draw something
  21.     CIRCLE (Path.Vector.X, Path.Vector.Y), 15, _RGB32(255, 0, 0)
  22.  
  23.     _DISPLAY
  24.  
  25. DATA 50,50,6,750,50,5,750,750,7,50,750,8,400,400,4,500,500,12,300,300,5,610,355,6,10,350,14
  26.  
  27. REM $INCLUDE:'UnseenGDK.BM'
  28.  
  29.  

Unseen

Offline codeguy

  • Forum Regular
  • Posts: 174
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #7 on: June 23, 2018, 01:40:22 am »
Attached is my circular sprite rotation sub. Rotates cw, ccw. Please feel free to use in your library or as necessary.

Code: QB64: [Select]
  1. h& = _LOADIMAGE(_CWD$ + "\mars.png", 32)
  2. DEMO& = _NEWIMAGE(1366, 768, 32)
  3. SCREEN DEMO&
  4. RotateStateX! = 0
  5.     GDKSpinCircularSprite h&, DEMO&, RotateStateX! * (2 * _PI) / 360
  6.     RotateStateX! = RotateStateX! + 5
  7.     _DISPLAY
  8. LOOP UNTIL RotateStateX! > 90
  9.  
  10. '************************
  11. '* codeguy circular sprite rotation tailored to UnseenMachine GDK library
  12. '************************
  13. SUB GDKSpinCircularSprite (source&, dest&, RotateStateX!)
  14.     osource& = _SOURCE
  15.     odest& = _DEST
  16.     _SOURCE source&
  17.     _DEST dest&
  18.     IF _WIDTH(source&) < _HEIGHT(source&) THEN
  19.         sourceimageradius% = _WIDTH(source&) / 2
  20.     ELSE
  21.         sourceimageradius% = _HEIGHT(source&) / 2
  22.     END IF
  23.     sourceimagecenter% = sourceimageradius%
  24.     IF sourceimageradius% > 0 THEN
  25.         DO
  26.             MINSTEP! = 1 / (2 * _PI * sourceimageradius%) '* codeguy famous minstep calculation
  27.             stepsaroundcircumference! = 0
  28.             DO
  29.                 sourcepixelx% = sourceimagecenter% + sourceimageradius% * COS(stepsaroundcircumference!)
  30.                 sourcepixely% = sourceimagecenter% + sourceimageradius% * SIN(stepsaroundcircumference!)
  31.                 desttranslatex% = sourceimagecenter% + sourceimageradius% * COS(stepsaroundcircumference! + RotateStateX!)
  32.                 desttranslatey% = sourceimagecenter% + sourceimageradius% * SIN(stepsaroundcircumference! + RotateStateX!)
  33.                 X& = POINT(sourcepixelx%, sourcepixely%)
  34.                 PSET (desttranslatex%, desttranslatey%), X&
  35.                 stepsaroundcircumference! = stepsaroundcircumference! + MINSTEP!
  36.             LOOP UNTIL stepsaroundcircumference! >= 2 * _PI
  37.             sourceimageradius% = sourceimageradius% - 1
  38.         LOOP UNTIL sourceimageradius% < 1
  39.     END IF
  40.     _SOURCE osource&
  41.     _DEST odest&
  42.  
« Last Edit: June 23, 2018, 01:45:06 am by codeguy »

Offline codeguy

  • Forum Regular
  • Posts: 174
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #8 on: June 23, 2018, 01:47:40 am »
I have used variable naming conventions that may help avoid conflicts. Always glad to help.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #9 on: June 23, 2018, 05:07:42 am »
@Unseen
That path one demo is cool! Can you also make circle to loop around the path instead of going back to origin?
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #10 on: June 23, 2018, 06:28:11 pm »
At my brother CG (For those who dont know, consider me his apprentice when it comes to coding!) - That Circular rotation is very cool! But, me...well id use it to convert the image to a circle, save it and then use my _MAPTRIAGLE rotation code as i reckon that way would be faster, i'd like to adapt it a little and then add it to my Image Function Library though if thats ok?

@ Asish - Yeah you can make it loop, just change the Reverse% variable to false (0) and the Repeat% variable to true (not a 0)

@ Everyone else...Attached is a .rar file containing files needed for upcoming demos.
Create a folder called "Unseen Demos" in your Qb64 directory and unzip it to there.

Unseen

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #11 on: June 23, 2018, 06:50:12 pm »
Demo - basic input, sprites 101 and vector movement (requires file from previous post)

Code: QB64: [Select]
  1. '// GDK Demos - No.3 - Input and movement using vectors.
  2.  
  3. '// For GDK 1.7
  4.  
  5. '// Root file path
  6. CHDIR "Unseen Demos\Resources\"
  7.  
  8. '// DIMension things, we need a Sprite array and a vector array
  9. DIM Sprite AS Sprite, Position AS Vector
  10.  
  11. '// Create keyboard state array
  12. DIM KB AS KeyBoardState
  13.  
  14. '// Create a screen
  15. GDK_Screen_SetRes Main&, 800, 600
  16.  
  17. '// Load the sprite (Handle, Filename$, XFrames, YFrames, Total Frames, Scale!
  18. GDK_Sprite_New Sprite, "Ship1.PNG", 1, 1, 1, 1
  19.  
  20. '// When loaded sprites need to have things done to them!
  21. GDK_Sprite_Show Sprite '// Make the sprite visible
  22.  
  23. '// The image background (we dont wanna see it) so we set it's ALPHA (_CLEARCOLOR) value, on this image it's bright pink!
  24. GDK_Sprite_SetAlpha Sprite, _RGB32(255, 0, 255)
  25.  
  26. '// Set where the image will be rotated from, we want it at the center
  27. GDK_Sprite_SetRotationAsCenter Sprite
  28.  
  29. '// Set sprite initial position
  30. Position.X = 400
  31. Position.Y = 300
  32.  
  33.  
  34.     _LIMIT 30
  35.     CLS
  36.  
  37.     '// User input
  38.     GDK_Keyboard_GetState KB
  39.  
  40.     '// Analyse input
  41.     IF KB.Left THEN
  42.         Position.Rotation = Position.Rotation + .0314
  43.     ELSEIF KB.Right THEN
  44.         Position.Rotation = Position.Rotation - .0314
  45.     END IF
  46.  
  47.     IF KB.Up THEN
  48.         IF Position.Speed < 5 THEN Position.Speed = Position.Speed + .2
  49.     ELSEIF KB.Down THEN
  50.         IF Position.Speed > -1 THEN Position.Speed = Position.Speed - .2
  51.     END IF
  52.  
  53.  
  54.     '// Update the position of the sprite's vector
  55.     GDK_Vector_Update Position
  56.  
  57.  
  58.     '// Draw the sprite
  59.     GDK_Sprite_Draw Sprite, Position, 1
  60.  
  61.     _DISPLAY
  62.  
  63.  
  64. REM $INCLUDE:'Unseengdk.bm'
  65.  


Unseen

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #12 on: June 23, 2018, 07:28:48 pm »
DEMO - Requires posted files.

use arrow keys to move, space turns rectangles on/off

Code: QB64: [Select]
  1. '// GDK Demos - Collision detection
  2.  
  3. '// For GDK 1.7
  4.  
  5. '// Root file path
  6. CHDIR "Unseen Demos\Resources\"
  7.  
  8. '// Now we will be using two sprites, for ease i've used an array
  9. '// Each sprite has an associated Vector and a Rectangle
  10. '// As the enemy sprite is animated it also has an Anim array
  11. DIM Sprite(1) AS Sprite, Position(1) AS Vector, Rect(1) AS Rectangle, Anim AS ANIMATION
  12.  
  13. '// Input handler
  14. DIM KB AS KeyBoardState
  15.  
  16. '// Variable for demo - To show collision rectangles
  17. ViewRect% = -1
  18.  
  19. '// Screen
  20. GDK_Screen_SetRes Main&, 800, 600
  21.  
  22. '// Load the sprites
  23. GDK_Sprite_New Sprite(0), "Ship1.PNG", 1, 1, 1, 1
  24. GDK_Sprite_New Sprite(1), "Invader1.PNG", 4, 1, 4, 1
  25.  
  26. '// Set the sprites up (Visibility, Alpha and rotation point)
  27. FOR i% = 0 TO 1
  28.     GDK_Sprite_Show Sprite(i%)
  29.     GDK_Sprite_SetAlpha Sprite(i%), _RGB32(255, 0, 255)
  30.     GDK_Sprite_SetRotationAsCenter Sprite(i%)
  31.  
  32. '// Set initial Vector values (position, rotation and speed)
  33.  
  34. '// ** NOTE -  GDK uses Radians to handle rotation values (0 to 2 * PI), Increasing turns CCW, Decreasing CW
  35.  
  36. Position(0).X = 400
  37. Position(0).Y = 300
  38. Position(1).X = 400
  39. Position(1).Y = 200
  40. Position(1).Speed = 2
  41. Position(1).Rotation = 3 * ATN(1)
  42.  
  43.  
  44. '// Set up enemy animation
  45. GDK_ANIMATION_NEW Anim, 1, 1, 4, .2, TIMER(.001)
  46.  
  47. '// Value to increase enemy rotation by
  48. EnemyRotInc! = (4 * ATN(1)) / 300
  49.  
  50.  
  51. '// Main loop
  52.  
  53.     _LIMIT 30
  54.     CLS
  55.  
  56.     '// User input
  57.     GDK_Keyboard_GetState KB
  58.  
  59.     IF KB.Left THEN
  60.         Position(0).Rotation = Position(0).Rotation + .0314
  61.     ELSEIF KB.Right THEN
  62.         Position(0).Rotation = Position(0).Rotation - .0314
  63.     END IF
  64.  
  65.     IF KB.Up THEN
  66.         IF Position(0).Speed < 5 THEN Position(0).Speed = Position(0).Speed + .2
  67.     ELSEIF KB.Down THEN
  68.         IF Position(0).Speed > -1 THEN Position(0).Speed = Position(0).Speed - .2
  69.     END IF
  70.  
  71.     '// Turn visable rectangles on/off
  72.     IF KB.SPACE THEN IF ViewRect% THEN ViewRect% = 0 ELSE ViewRect% = -1
  73.  
  74.     '// Increase enemy rotation
  75.     Position(1).Rotation = Position(1).Rotation + EnemyRotInc!
  76.  
  77.     '// Loop through the sprite array and do stuff
  78.     FOR i% = 0 TO 1
  79.  
  80.         '// Update the position of each sprite's vector
  81.         GDK_Vector_Update Position(i%)
  82.  
  83.         '// Autosize the sprites collision rectangle
  84.         '// Thanks to Richard Notely the rectangles actually rotate with the image!
  85.         GDK_Rectangle_Autosize Sprite(i%), Position(i%), Rect(i%)
  86.  
  87.         '// Update animation
  88.         GDK_ANIMATION_UPDATE Anim
  89.  
  90.         '// Draw the sprite's
  91.         IF i% = 0 THEN Frame% = 1 ELSE Frame% = Anim.Frame
  92.         GDK_Sprite_Draw Sprite(i%), Position(i%), Frame%
  93.  
  94.         '// DEMO CODE - To show actual collision rectangles
  95.         IF ViewRect% THEN
  96.             LINE (Rect(i%).C1.X, Rect(i%).C1.Y)-(Rect(i%).C2.X, Rect(i%).C2.Y), _RGB32(255, 0, 0)
  97.             LINE (Rect(i%).C2.X, Rect(i%).C2.Y)-(Rect(i%).C3.X, Rect(i%).C3.Y), _RGB32(255, 0, 0)
  98.             LINE (Rect(i%).C3.X, Rect(i%).C3.Y)-(Rect(i%).C4.X, Rect(i%).C4.Y), _RGB32(255, 0, 0)
  99.             LINE (Rect(i%).C4.X, Rect(i%).C4.Y)-(Rect(i%).C1.X, Rect(i%).C1.Y), _RGB32(255, 0, 0)
  100.         END IF
  101.  
  102.     NEXT
  103.  
  104.     '// Check for collision
  105.     IF GDK_Rectangle_Intersect(Rect(0), Rect(1)) THEN LOCATE 1, 1: PRINT "COLLISION"
  106.  
  107.  
  108.  
  109.     _DISPLAY
  110.  
  111.  
  112.  
  113. '// Library inclusion
  114. REM $INCLUDE:'Unseengdk.bm'


youll see that collisions are not pixel perfect, and intentionally so...typical practice is to use rectangles that are slightly smaller than the actual image, usually about 80%...here's how you would modify the above to achieve that.

Code: QB64: [Select]
  1. '// GDK Demos - Collision detection
  2.  
  3. '// For GDK 1.7
  4.  
  5. '// Root file path
  6. CHDIR "Unseen Demos\Resources\"
  7.  
  8. '// Now we will be using two sprites, for ease i've used an array
  9. '// Each sprite has an associated Vector and a Rectangle
  10. '// As the enemy sprite is animated it also has an Anim array
  11. DIM Sprite(1) AS Sprite, Position(1) AS Vector, Rect(1) AS Rectangle, Anim AS ANIMATION
  12.  
  13. '// Input handler
  14. DIM KB AS KeyBoardState
  15.  
  16. '// Variable for demo - To show collision rectangles
  17. ViewRect% = -1
  18.  
  19. '// Screen
  20. GDK_Screen_SetRes Main&, 800, 600
  21.  
  22. '// Load the sprites
  23. GDK_Sprite_New Sprite(0), "Ship1.PNG", 1, 1, 1, 1
  24. GDK_Sprite_New Sprite(1), "Invader1.PNG", 4, 1, 4, 1
  25.  
  26. '// Set the sprites up (Visibility, Alpha and rotation point)
  27. FOR i% = 0 TO 1
  28.     GDK_Sprite_Show Sprite(i%)
  29.     GDK_Sprite_SetAlpha Sprite(i%), _RGB32(255, 0, 255)
  30.     GDK_Sprite_SetRotationAsCenter Sprite(i%)
  31.  
  32. '// Set initial Vector values (position, rotation and speed)
  33.  
  34. '// ** NOTE -  GDK uses Radians to handle rotation values (0 to 2 * PI), Increasing turns CCW, Decreasing CW
  35.  
  36. Position(0).X = 400
  37. Position(0).Y = 300
  38. Position(1).X = 400
  39. Position(1).Y = 200
  40. Position(1).Speed = 2
  41. Position(1).Rotation = 3 * ATN(1)
  42.  
  43.  
  44. '// Set up enemy animation
  45. GDK_ANIMATION_NEW Anim, 1, 1, 4, .2, TIMER(.001)
  46.  
  47. '// Value to increase enemy rotation by
  48. EnemyRotInc! = (4 * ATN(1)) / 300
  49.  
  50.  
  51. '// Main loop
  52.  
  53.     _LIMIT 30
  54.     CLS
  55.  
  56.     '// User input
  57.     GDK_Keyboard_GetState KB
  58.  
  59.     IF KB.Left THEN
  60.         Position(0).Rotation = Position(0).Rotation + .0314
  61.     ELSEIF KB.Right THEN
  62.         Position(0).Rotation = Position(0).Rotation - .0314
  63.     END IF
  64.  
  65.     IF KB.Up THEN
  66.         IF Position(0).Speed < 5 THEN Position(0).Speed = Position(0).Speed + .2
  67.     ELSEIF KB.Down THEN
  68.         IF Position(0).Speed > -1 THEN Position(0).Speed = Position(0).Speed - .2
  69.     END IF
  70.  
  71.     '// Turn visable rectangles on/off
  72.     IF KB.SPACE THEN IF ViewRect% THEN ViewRect% = 0 ELSE ViewRect% = -1
  73.  
  74.     '// Increase enemy rotation
  75.     Position(1).Rotation = Position(1).Rotation + EnemyRotInc!
  76.  
  77.     '// Loop through the sprite array and do stuff
  78.     FOR i% = 0 TO 1
  79.  
  80.         '// Update the position of each sprite's vector
  81.         GDK_Vector_Update Position(i%)
  82.  
  83.         '' Store the scale value, change it then put it back
  84.         OldScale! = Sprite(i%).Scale
  85.         Sprite(i%).Scale = 80 * (Sprite(i%).Scale / 100)
  86.  
  87.         '// Autosize the sprites collision rectangle
  88.         '// Thanks to Richard Notely the rectangles actually rotate with the image!
  89.         GDK_Rectangle_Autosize Sprite(i%), Position(i%), Rect(i%)
  90.  
  91.         '// reset scale value
  92.         Sprite(i%).Scale = OldScale!
  93.  
  94.         '// Update animation
  95.         GDK_ANIMATION_UPDATE Anim
  96.  
  97.         '// Draw the sprite's
  98.         IF i% = 0 THEN Frame% = 1 ELSE Frame% = Anim.Frame
  99.         GDK_Sprite_Draw Sprite(i%), Position(i%), Frame%
  100.  
  101.         '// DEMO CODE - To show actual collision rectangles
  102.         IF ViewRect% THEN
  103.             LINE (Rect(i%).C1.X, Rect(i%).C1.Y)-(Rect(i%).C2.X, Rect(i%).C2.Y), _RGB32(255, 0, 0)
  104.             LINE (Rect(i%).C2.X, Rect(i%).C2.Y)-(Rect(i%).C3.X, Rect(i%).C3.Y), _RGB32(255, 0, 0)
  105.             LINE (Rect(i%).C3.X, Rect(i%).C3.Y)-(Rect(i%).C4.X, Rect(i%).C4.Y), _RGB32(255, 0, 0)
  106.             LINE (Rect(i%).C4.X, Rect(i%).C4.Y)-(Rect(i%).C1.X, Rect(i%).C1.Y), _RGB32(255, 0, 0)
  107.         END IF
  108.  
  109.     NEXT
  110.  
  111.     '// Check for collision
  112.     IF GDK_Rectangle_Intersect(Rect(0), Rect(1)) THEN LOCATE 1, 1: PRINT "COLLISION"
  113.  
  114.  
  115.  
  116.     _DISPLAY
  117.  
  118.  
  119.  
  120. '// Library inclusion
  121. REM $INCLUDE:'Unseengdk.bm'
Unseen

Offline codeguy

  • Forum Regular
  • Posts: 174
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #13 on: June 23, 2018, 07:41:57 pm »
Adapt as you wish, UnseenMachine.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Unseen GDK - Dev Thread
« Reply #14 on: June 24, 2018, 02:50:01 am »
@ Asish - Yeah you can make it loop, just change the Reverse% variable to false (0) and the Repeat% variable to true (not a 0)
I try it. But it is not working as expected. Is I'm doing anything wrong?

Code: QB64: [Select]
  1. '// UnseenGDK Demo - Path Movement using absolute screen co-ordinates
  2.  
  3. '// Create Screen
  4. GDK_Screen_SetRes Main&, 800, 700 'replaced 800 with 700 because, I've 1366x768 desktop
  5.  
  6. '// DIMension arrays for path points (X, Y, Speed)
  7. DIM Path AS Path, PathPoints(7) AS PathPoint
  8.  
  9. '// Load path points
  10. '// SUB GDK_Path_New (Path AS Path, PathPoint() AS PathPoint, NumPoints%, Reverse%, Repeat%, Relative%)
  11. GDK_Path_New Path, PathPoints(), 8, 0, 1, 0
  12.  
  13. '// Main loop
  14.     _LIMIT 30
  15.     CLS
  16.  
  17.     '// Update path
  18.     GDK_Path_Update Path, PathPoints()
  19.     FOR i = 0 TO 7
  20.         CIRCLE (PathPoints(i).X, PathPoints(i).Y), 5, _RGB(255, 255, 0)
  21.     NEXT i
  22.  
  23.     '// Draw something
  24.     CIRCLE (Path.Vector.X, Path.Vector.Y), 15, _RGB32(255, 0, 0)
  25.  
  26.     _DISPLAY
  27.  
  28. DATA 50,50,6,650,50,5,650,650,7,50,650,8,400,400,4,500,500,12,300,300,5,610,355,6,10,350,14
  29.  
  30. REM $INCLUDE:'UnseenGDK_Dev.BM'
  31.  
  32.  
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials