November 24, 2020, 07:01:08 AM

Author Topic: [bmx] boardgame creator by Mainsworthy [ 1+ years ago ]  (Read 599 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] boardgame creator by Mainsworthy [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : boardgame creator
Author : Mainsworthy
Posted : 1+ years ago

Description : A basic starting block of code to create your own boardgames

Code :
Code: BlitzMax
  1. 'you must provide 2 files for this program to work troops.png 20 pixels high 40 across 2 chits
  2. 'a 1024x768 backdrop
  3.  
  4. Graphics 1024,768,32,60
  5. Global chit = LoadAnimImage(".  roops.PNG",20,20,0,2,flags=ALPHABITS  ) '2 twenty by twenty chits
  6. Global backdrop = LoadImage(".ackdrop.PNG"  ) 'plain backdrop
  7.  
  8. Global gameboard[10,10,20] '10 x 10 grid gameboard with 20 items of info per location
  9. Global x1 = 0
  10. Global y1 = 0
  11. 'try setting the gameboard as shown below
  12. gameboard[1,1,1] = 1
  13. gameboard[1,3,1] = 1
  14.  
  15.  
  16. While Not KeyHit(KEY_ESCAPE) 'hit escape to exit
  17.  
  18. Cls 'clear screen before redrawing each loop through
  19.  
  20. DrawImage(backdrop ,0,0) 'draw backdrop
  21.  
  22. 'use a for next loop to draw chits
  23. For x= 0 To 9
  24. For y = 0 To 9
  25. If gameboard[x,y,1] = 1 Then DrawImage(chit,x*20,y*20,frame=1) 'frame is chit number
  26. Next
  27. Next
  28.  
  29. ' devise x and y by 20 pixels, this is because the chits are 20 pixels
  30. 'the idea is to find where the mouse pointer is
  31. x1 = MouseX() /20
  32. y1 = MouseY() /20
  33.  
  34. 'this sets gameboard on off by left or right clicking
  35. If x1 < 10 And x1 > -1 And y1 < 10 And y1 > -1
  36. If MouseDown(1) 'Left click set on
  37. gameboard[x1,y1,1] = 1
  38. EndIf
  39. If MouseDown(2) 'right click set off
  40. gameboard[x1,y1,1] = 0
  41. EndIf
  42. EndIf
  43.  
  44.  
  45.  
  46. Flip 'this flips the board onto the screen
  47.  
  48. Wend
  49.  
  50. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal