BlitzMax (free download after creating an account at blitzbasic.com)

Started by gameleaper, September 21, 2015, 08:43:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gameleaper

I being broad in my discriptions, you have to learn to make your variables global by putting global before the variable name at the beginning of the program, so the program remembers the variable throughout the game, and you have to be carefull not to go beyond the boundries of the grid or your program will crash, for example adding z to x can give an out of bounds error, you have to check this, you can also put safeguards in to avoid this like this If z+x < 50 and z+x > 0 then draw chit

Im a bit of an error here z x and ys. just use 4 differren letters as vvariables  like these z,x,q,w,

gameleaper

you can only learn by experiencing each brick at a time, try it out for yourself is the only way. I hope Ive given you enough to begin

gameleaper

you put it altogether like this.

first off if you left-click you find what hex your over, then draw a yellow box there, then left-ckick a second hex and move the first to the second location like this

FOR f= 0 to 20
(leftclickedX,LeftclicedY,f) = (firstleftclickedX,firstLeftclicedY,f)
NEXT

and this will move all the info to next hex, remember to delete the first hex info afterwards

gameleaper

I wont write anymore, its enough for you to get started I hope :)

bbmike

Professor gameleaper, please teach the first ever Grogheads class...  O0
"My life is spent in one long effort to escape from the commonplace of existence."
-Sherlock Holmes

"You know, just once I'd like to meet an alien menace that wasn't immune to bullets."
-Brigadier Lethbridge-Stewart

"There's a horror movie called Alien? That's really offensive. No wonder everyone keeps invading you!"
-The Doctor

"Before Man goes to the stars he should learn how to live on Earth."
-Clifford D. Simak

gameleaper

Quote from: bbmike on September 25, 2015, 06:20:58 PM
Professor gameleaper, please teach the first ever Grogheads class...  O0

:) thanks bb -  hey I think GJK may do a wargame, I hope I have helped a bit. also the games made with Blitz are small so easy to share.

GJK

That's what I'm talking about gl!  I need to make sure that my copy of Blitzmax is up to date (I know that it's not) and then I'll start tinkering around.  Great stuff, thanks!
Clip your freaking corners!
----------------------
Blood Bowl on VASSAL - Ask me about it! http://garykrockover.com/BB/
----------------------
"Fat, drunk, and stupid is no way to go through life, son."

-Dean Vernon Wormer

gameleaper

Quote from: GJK on September 25, 2015, 09:46:39 PM
That's what I'm talking about gl!  I need to make sure that my copy of Blitzmax is up to date (I know that it's not) and then I'll start tinkering around.  Great stuff, thanks!


you must provide 2 files for this program to work troops.png 20 pixels high 40 across 2 chits
'a 1024x768 backdrop

Graphics 1024,768,32,60
Global chit = LoadAnimImage(".\troops.PNG",20,20,0,2,flags=ALPHABITS  ) '2 twenty by twenty chits
Global backdrop = LoadImage(".\backdrop.PNG"  ) 'plain backdrop

Global gameboard[10,10,20] '10 x 10 grid gameboard with 20 items of info per location
Global x1 = 0
Global y1 = 0
'try setting the gameboard as shown below
gameboard[1,1,1] = 1
gameboard[1,3,1] = 1


While Not KeyHit(KEY_ESCAPE) 'hit escape to exit

Cls 'clear screen before redrawing each loop through

DrawImage(backdrop ,0,0) 'draw backdrop

'use a for next loop to draw chits
For x= 0 To 9
For y = 0 To 9
If gameboard[x,y,1] = 1 Then DrawImage(chit,x*20,y*20,frame=1) 'frame is chit number
Next
Next

' devise x and y by 20 pixels, this is because the chits are 20 pixels
'the idea is to find where the mouse pointer is
x1 = MouseX() /20
y1 = MouseY() /20

'this sets gameboard on off by left or right clicking
If x1 < 10 And x1 > -1 And y1 < 10 And y1 > -1
If MouseDown(1) 'Left click set on
gameboard[x1,y1,1] = 1
EndIf
If MouseDown(2) 'right click set off
gameboard[x1,y1,1] = 0
EndIf
EndIf



Flip 'this flips the board onto the screen

Wend

End





gameleaper

the text after the ' quote are info only text and can be omitted

the program above will draw a board and chits, that you can test and change, its just to show you how to start

its 0 to 9 arrays start at 0, and end 1 less than than you say in the global statement.

the above code snippet is real and will run in BlitzMax , nearly all you need is there.

gameleaper


gameleaper

' just tested the code works fine , I just typed it out without testing all fixed now

you must provide 2 files for this program to work troops.png 20 pixels high 40 across 2 chits
'a 1024x768 backdrop

Graphics 1024,768,32,60
Global chit = LoadAnimImage(".\troops.PNG",20,20,0,2,flags=ALPHABITS  ) '2 twenty by twenty chits
Global backdrop = LoadImage(".\backdrop.PNG"  ) 'plain backdrop

Global gameboard[10,10,20] '10 x 10 grid gameboard with 20 items of info per location
Global x1 = 0
Global y1 = 0
'try setting the gameboard as shown below
gameboard[1,1,1] = 1
gameboard[1,3,1] = 1


While Not KeyHit(KEY_ESCAPE) 'hit escape to exit

Cls 'clear screen before redrawing each loop through

DrawImage(backdrop ,0,0) 'draw backdrop

'use a for next loop to draw chits
For x= 0 To 9
For y = 0 To 9
If gameboard[x,y,1] = 1 Then DrawImage(chit,x*20,y*20,frame=1) 'frame is chit number
Next
Next

' devise x and y by 20 pixels, this is because the chits are 20 pixels
'the idea is to find where the mouse pointer is
x1 = MouseX() /20
y1 = MouseY() /20

'this sets gameboard on off by left or right clicking
If x1 < 10 And x1 > -1 And y1 < 10 And y1 > -1
If MouseDown(1) 'Left click set on
gameboard[x1,y1,1] = 1
EndIf
If MouseDown(2) 'right click set off
gameboard[x1,y1,1] = 0
EndIf
EndIf



Flip 'this flips the board onto the screen

Wend

End




gameleaper

the 2 graphic files need to be next to the exe file, just drop them in the blitzmax folder. Ive tested the code

this program is nearly all you need to write a game

gameleaper

you must provide 2 files for this program to work troops.png 20 pixels high 40 across 2 chits
'a 1024x768 backdrop

Graphics 1024,768,32,60
Global chit = LoadAnimImage(".\troops.PNG",20,20,0,2,flags=ALPHABITS  ) '2 twenty by twenty chits
Global backdrop = LoadImage(".\backdrop.PNG"  ) 'plain backdrop

Global gameboard[10,10,20] '10 x 10 grid gameboard with 20 items of info per location
Global x1 = 0
Global y1 = 0
'try setting the gameboard as shown below
gameboard[1,1,1] = 1
gameboard[1,3,1] = 1


While Not KeyHit(KEY_ESCAPE) 'hit escape to exit

Cls 'clear screen before redrawing each loop through

DrawImage(backdrop ,0,0) 'draw backdrop

'use a for next loop to draw chits
For x= 0 To 9
For y = 0 To 9
If gameboard[x,y,1] = 1 Then DrawImage(chit,x*20,y*20,frame=1) 'frame is chit number
Next
Next

' devise x and y by 20 pixels, this is because the chits are 20 pixels
'the idea is to find where the mouse pointer is
x1 = MouseX() /20
y1 = MouseY() /20

'this sets gameboard on off by left or right clicking
If x1 < 10 And x1 > -1 And y1 < 10 And y1 > -1
If MouseDown(1) 'Left click set on
gameboard[x1,y1,1] = 1
EndIf
If MouseDown(2) 'right click set off
gameboard[x1,y1,1] = 0
EndIf
EndIf



Flip 'this flips the board onto the screen

Wend

End




gameleaper

Ok you got me on  a roll, finished now. the above code is tested.

the code now allows you to set the chits on the board on off.