Rorkes Drift

Community Forums/Showcase/Rorkes Drift

Mainsworthy(Posted 2016) [#1]









https://numbergamer8.itch.io/rorkes-drift

turn-based hex wargame, based on an older engine, but updated for better unit display, its only for windows at the moment. its free


Mainsworthy(Posted 2016) [#2]
Ive added an ACW module I have changed ranges from melee to musket for units, and added a hotseat version to allow both sides to be played.

https://numbergamer8.itch.io/rorkes-drift


skidracer(Posted 2016) [#3]
Hi Mark, I have removed the duplicate thread as the Showcase forum is intended as single topic per project.


Mainsworthy(Posted 2016) [#4]
sorry for multiposts.

Ive added a Roman and sparticus module

https://numbergamer8.itch.io/rorkes-drift


cps(Posted 2016) [#5]
Looks good to an old hex based game player like myself, nice one. Have you done any similar games using two computers/players ?
A peek at your source code would maybe provide other users with pointers to their own program development (speaking as a user who finds practical examples more informative than instruction manuals). Have fun cps.


Mainsworthy(Posted 2016) [#6]
Hi cps, I'm glad to see there are other hex players on here, Ive done lots of games here https://numbergamer8.itch.io/ the game has A.I. aswell as HotSeat, there are 3 versions in the zip. if you mean running computer against computer - I have never tried it . some of the games online I have provided source code with( space pirate & RPG Legend, I cant remember what others) My source is a mess I'm the only one that can follow it, and anyone who see it always says I'm not doing it right, but I'm still making games so whos correct :)


Mainsworthy(Posted 2016) [#7]
'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


Mainsworthy(Posted 2016) [#8]
'this is a hexgrid, with 40x40 size
'you must provide 2 files for this program to work troops.png 40 pixels high 80 across 2 chits
'a 1024x768 backdrop

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

Global gameboard[40,40,40] '40 x 40 grid gameboard with 40 items of info per location
Global x1 = 0
Global y1 = 0
Global shift = 0

Global sa = 0
Global ba = 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

drawhexgrid() 'call the function to draw hexgrid







x1 = MouseX() /40
y1 = MouseY() /40

'this adjusts the code for a hexgrid rather than squares
shift = 0 'initialise shift
If x1 = 0 Or x1 = 2 Or x1 = 4 Or x1 = 6 Or x1 = 8 Or x1 = 10 Or x1 = 12 Or x1 = 14 Or x1 = 16 Or x1 = 18 Or x1 = 20 Or x1 = 22 Or x1 = 24 Or x1 = 26 Then shift = 1
If shift = 1
y1 = (MouseY()-20) /40 '-20 because the +20 we added in the display loop and the mousey
EndIf

'use a for next loop to draw chits
For x= 0 To 26
For y = 0 To 16

shift = 0 'initialise shift
If x = 0 Or x = 2 Or x = 4 Or x = 6 Or x = 8 Or x = 10 Or x = 12 Or x = 14 Or x = 16 Or x = 18 Or x = 20 Or x = 22 Or x = 24 Or x = 26 Then shift = 1 'check to see if we are on a shifted down hex
If gameboard[x,y,1] = 1 And shift = 0 Then DrawImage(chit,x*40,y*40,frame=1) 'frame is chit number 1 or 2
If gameboard[x,y,1] = 1 And shift = 1 Then DrawImage(chit,x*40,(y*40)+20,frame=1) 'frame is chit number 1 or 2, adds 10 to Y(down)

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




'this sets gameboard on off by left or right clicking
If x1 < 25 And x1 > 0 And y1 < 16 And y1 > -1 'x has 25 across, y has 16 down
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

Function drawhexgrid()

' the loops draw 6 hexsides and repeat through the loops

a = 80
b = 0
c = 80
d = 0

For a2 = 0 To 15
For a1 = 0 To 26 Step 2
DrawLine(5+a,20+b,35+c,20+d)
DrawLine(35+a,20+b,45+c,40+d)
DrawLine(45+a,40+b,35+c,60+d)
DrawLine(35+a,60+b,5+c,60+d)
DrawLine(5+a,60+b,-5+c,40+d)
DrawLine(-5+a,40+b,5+c,20+d)
a=a+80
c=c+80
Next
a = 80
c = 80
b = b+40
d = d+40
Next

a = 40
b = -20
c = 40
d = -20

For a2 = 0 To 15
For a1 = 0 To 23 Step 2
DrawLine(5+a,20+b,35+c,20+d)
DrawLine(35+a,20+b,45+c,40+d)
DrawLine(45+a,40+b,35+c,60+d)
DrawLine(35+a,60+b,5+c,60+d)
DrawLine(5+a,60+b,-5+c,40+d)
DrawLine(-5+a,40+b,5+c,20+d)
a=a+80
c=c+80
Next
a = 40
c = 40
b = b+40
d = d+40
Next





End Function

End


cps(Posted 2017) [#9]
Thanks, I'll have a look at your code for the games you mentioned. I wouldn't worry about your code, if it works it's fine. Code will evolve (hopefully for the better) the more you do it.
Brief question, Do you use Type 'unit' with a field 'position' or Type 'Hex' with a field 'unit'(in this hex) to track unit positions. I've tried both ways and found each have their merits.
I have just tried both methods in one program but that turned out bad. Hope my question makes sense. Happy New Year, have fun cps
PS By two computers/players I meant one player at one computer and another player at another, connected by LAN or WAN(internet)


gpete(Posted 2017) [#10]
Main's- nice old fashioned hex game- reminds me of some old Spectrum-C64-PC & even Amiga games. And I have played board hex wargames since 12 yrs old- ( 1967 !).


cps(Posted 2017) [#11]
'gpete' Didn't start till my mid 20's (early 80's) so you have a lead on me there. Question; Have you ever tried programing one? I'm building up to a thirty year war one using 2 networked cpu's (based on the rules used by the Avlon Hill range), so I'm hoping to pick over some of 'mains' code to get some hints. Have fun cps


gpete(Posted 2017) [#12]
CPS, yes I have - I made an hex war game for my C64 which worked but was pretty crude. Also I have designed a number of home-brew "board" wargames for fun and miniatures- At the moment I am building 3D models of WW2 tanks for a North Africa based B3D game or maybe a "Landships" type game. And yes I have looked at the networking code for multiplayer games...not figured it out yet!

If I had stayed in Redmond Wash. in 1980 I'm sure I would have worked for Microsoft..I was working early datatech Hewlett-Packard stuff down the hill from the "later" MS campus. Worked and went to college at nights - took C, Pascal, COBOL, Fortran and Visual Basic classes. Retired now but spent my last 8 years doing graphical and tabular database reports using Visual Basic for Applications code I designed.


cps(Posted 2017) [#13]
'gpete' Nice.. Hope I'm not subverting the thread but being as how you have a handle on VB have you looked at Direct Play? P2P and client server networking.
I used a series of articles by Jack Hoxley At http://directx4vb.vbgamer.com/ which provided a simple bit of code to generate a GUID as well as a basic P2P chat prog to get me started..
Always keen to encourage hard work by others. Have fun cps


Mainsworthy(Posted 2017) [#14]
gpete your a bit older than me, not by much, your the sort of person I made this game for, thanks for telling me your out there.