Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / The Reversi Challange

Author
Message
Invader Awesome
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 12th Feb 2008 10:59
Okay, so its a chalalnge for me, not for you.

Im new to dark basic and im attempting to make a simple Reversi game for my first project.

I know its not complete but i cant think of what to do next. If you can provide any help it'll be much appreciated.

if check display mode (800, 600, 16)=1
set display mode 800,600,16
endif
cls rgb(20, 120, 20)

sync on
do
FindMouseCell()
sync
wait 50
loop

` Load images for sprites
` Load music and loop throghout
load image "F:\HNC Game Development\Programming\Media\NewGame.bmp", 1
load image "F:\HNC Game Development\Programming\Media\LoadGame.bmp", 2
load image "F:\HNC Game Development\Programming\Media\SaveGame.bmp", 3
load image "F:\HNC Game Development\Programming\Media\WhiteScoreCounter.png", 4
load image "F:\HNC Game Development\Programming\Media\BlackScorecounter.png", 5
load music "F:\HNC Game Development\Programming\Media\Watch.mp3",1
loop music 1

` Outline Box
ink rgb(255,255,255),rgb(0,0,0)
line 149,24, 649,24
line 149,24, 149,574
line 149,574,649,574
line 649,24, 649,574

` Vertical Lines of Box
line 199,99, 199,499
line 249,99, 249,499
line 299,99, 299,499
line 349,99, 349,499
line 399,99, 399,499
line 449,99, 449,499
line 499,99, 499,499
line 549,99, 549,499
line 599,99, 599,499

` Horizontal Lines
line 199,99, 599,99
line 199,149, 599,149
line 199,199, 599,199
line 199,249, 599,249
line 199,299, 599,299
line 199,349, 599,349
line 199,399, 599,399
line 199,449, 599,449
line 199,499, 599,499

` Importing sprites
sprite 1,199,49,1
Set Sprite 1,0,1

sprite 2,349,49,2
Set Sprite 2,0,1

sprite 3,499,49,3
Set sprite 3,0,1

sprite 4,199,501,4
Set sprite 4,0,1

sprite 5,399,501,5
set sprite 4,0,1

` Declare Starting Grid
dim x(7) as integer
dim y(7) as integer
dim x_y(7,7) as integer

` Mouse Cell
Mx1 as integer 199
Mx2 as integer 249
Mx3 as integer 299
Mx4 as integer 349
Mx5 as integer 399
Mx6 as integer 449
Mx7 as integer 499
Mx8 as integer 549
Mx9 as integer 599


My1 as integer 99
My2 as integer 149
My3 as integer 199
My4 as integer 249
My5 as integer 299
My6 as integer 349
My7 as integer 399
My8 as integer 449
My9 as ingeter 499

` Board
dim Blank() as integer = 0
dim Black() as integer = 1
dim White() as integer = 2

` Score
` Starts at two for both players
blackScore as integer = 2
whiteScore as integer = 2

` Function to begin game
Function startGame(x_y)

` Nested For to loop to intialise grid
for x = 0 to 7
for y = 0 to 7
if x = 3 AND y = 3 OR x = 4 AND y = 4 THEN
x_y(x,y) = black
`insert code to place black object on grid
if x = 3 AND y = 4 OR x = 4 AND y = 3 THEN
x_y(x,y) = white
`insert code to place white object on grid
if x_y(x,y)NOT = white AND x_y(x,y)NOT = black THEN
x_y(x,y) = blank
`insert code to place blank object
NEXT y
NEXT x
EndFunction

` Update Score
` Is only to be called to update the score
` It DOES NOT handle the moves or determine
` if the board is full
Function updateScore(x_y)
` To check if the score limit has been
` been reached and the winner can be
` determined
if blackScore = 64 THEN
` Call the black wins function
` Alternatively pass black to
` a winner fuction.
If whiteScore = 64 THEN
` Call the white wins function
` Alternatively pass white to a winner fuction.
` Insert another counter to count the number of blacks and whites
` Since the number of blacks or whites may be less each time the move
` has been made. et score to the value of the counters within this function
for x = 0 to 7
for y = 0 to 7
` If the box is black the black score is incremented by 1
if x_y(x,y) = black THEN
INC blackScore
` If the box is black the white score is incremented by 1
if x_y(x,y) = white THEN
INC whiteScore
NEXT y
NEXT x
EndFunction



global linewidth as integer = 20
global dim cell (9) as integer

function findmousecell
x = mousex ()
y = mousey ()
text 0, 0, "cell 0 " + str$(x) + " " + str$(y)
if x >=x1 and x < x2 and y >=y1 and y < y2
text 0, 0, "cell 1"
endif
if x >=x2+linewidth and x < x3 and y >=y1 and y < y2
text 0, 0, "cell 2"
endif
if x >=x3+linewidth and x < x4 and y >=y1 and y < y2
text 0, 0, "cell 3"
endif
if x >=x1 and x < x2 and y >=y2+linewidth and y < y3
text 0, 0, "cell 4"
endif
if x >=x2+linewidth and x < x3 and y >=y2+linewidth and y < y3
text 0, 0, "cell 5"
endif
if x >=x3+linewidth and x < x4 and y >=y2+linewidth and y < y3
text 0, 0, "cell 6"
endif
if x >=x1 and x < x2 and y >=y3+linewidth and y < y4
text 0, 0, "cell 7"
endif
if x >=x2+linewidth and x < x3 and y >=y3+linewidth and y < y4
text 0, 0, "cell 8"
endif
if x >=x3+linewidth and x < x4 and y >=y3+linewidth and y < y4
text 0, 0, "cell 9"
endif
endfunction

X = MouseX()
Y = MouseY()
Text 0, 0, "Cell 0"
If X => X1 and X =< X2 and Y => Y1 and Y =<Y2
Text 0,0, "Cell 1"
endif
endfunction

` Global Buttons
global clicked
global hover
global press

cls

while clicked<>1
ink RGB(0, 0, 255),RGB(0, 0, 160)
box screen width()/2-50, screen height()/2-12, screen width()/2+50, screen height()/2+12

if mousein(screen width()/2-50, screen width()/2+50, screen height()/2-12, screen height()/2+12)=1
ink RGB(255,0,0),RGB(0, 0, 160)
box screen width()/2-48, screen height()/2-10, screen width()/2+48, screen height()/2+10
endif
if mousein(screen width()/2-50, screen width()/2+50, screen height()/2-12, screen height()/2+12)=0
ink RGB(0, 128, 255),RGB(0, 0, 160)
box screen width()/2-48, screen height()/2-10, screen width()/2+48, screen height()/2+10
endif
if mousein(screen width()/2-50, screen width()/2+50, screen height()/2-12, screen height()/2+12)=1
if mouseclick()=1
while mouseclick()=1
ink RGB(255, 255, 0),RGB(0, 0, 160)
box screen width()/2-48, screen height()/2-10, screen width()/2+48, screen height()/2+10
ink RGB(0, 0, 0),RGB(0,0,160)
center text screen width()/2, screen height()/2-7, "Ok"
endwhile
if mousein(screen width()/2-50, screen width()/2+50, screen height()/2-12, screen height()/2+12)=1
clicked=1
endif
endif
endif
ink RGB(0,0,0), RGB(0, 0, 160)
center text screen width()/2, screen height()/2-8, "Ok"
endwhile

end

Valera Is Gay
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 12th Feb 2008 13:08
i dont have the time right now to play that, but i can tell you that instead of just pasting onto the post, use the code brackets...


also not sure, but it seems like when you draw lines, you could save some time and use a for next loop... the line increments seem even enough


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/

Login to post a reply

Server time is: 2024-05-06 18:02:42
Your offset time is: 2024-05-06 18:02:42