Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create a board game
#1
I was thinking about how I could create a game similar to the game of checkers but I have no idea how to start.

Does anyone know how to create this type of game or something similar to have a base and be able to create more games of that style.

I put a link to a video in case I was not understood correctly.

https://www.youtube.com/watch?v=r-7R2sCW3Ro
Reply
#2
I implemented Connect Four (https://en.m.wikipedia.org/wiki/Connect_Four) and Sudoku in some early version of naalaa, but that's about it.

The biggest difficulty with most of these games is creating a good computer opponent (well, not in Sudoku).
Reply
#3
My question is not very specific, I start from scratch with something simpler. How do I move the pieces diagonally on a board?
Reply
#4
My first guess... Imagine the player is at coordinates 0,0 on an x,y grid.
Move x to the left: negative. Right: positive
Move y up: negative. Down: positive.

up-left would be x-1,y-1
up-right would be x+1,y-1
down-left would be x-1,y+1
down-right would be x+1,y+1

I hope this helps...
Logic is the beginning of wisdom.
Reply
#5
(02-13-2024, 09:12 PM)johnno56 Wrote: My first guess... Imagine the player is at coordinates 0,0 on an x,y grid.
Move x to the left: negative. Right: positive
Move y up: negative. Down: positive.

up-left would be x-1,y-1
up-right would be x+1,y-1
down-left would be x-1,y+1
down-right would be x+1,y+1

I hope this helps...

It might work yes, thanks johnno56
Reply
#6
We are both learning on this particular topic... I have never "created" a board game (programmed from scratch) before. But, since you have raised the subject, I have been researching board games and how they are coded. I can see how this could be quite addictive!

Making games like Checkers and Chess etc. have always been on my "to do" list, but have never really summoned up enough courage, to actually make a commitment... lol I am hoping this will change...

I had a weird idea about board design and player movement... N7 has a "TileMap Editor" that could be used to both create the board and move the player(s)... Not exactly sure how to do that, but I imagine that it could be done... Could save a LOT of work... more research!! Cool... Yes. Quite addictive...
Logic is the beginning of wisdom.
Reply
#7
(02-14-2024, 07:10 PM)johnno56 Wrote: We are both learning on this particular topic... I have never "created" a board game (programmed from scratch) before. But, since you have raised the subject, I have been researching board games and how they are coded. I can see how this could be quite addictive!

Making games like Checkers and Chess etc. have always been on my "to do" list, but have never really summoned up enough courage, to actually make a commitment... lol  I am hoping this will change...

I had a weird idea about board design and player movement... N7 has a "TileMap Editor" that could be used to both create the board and move the player(s)... Not exactly sure how to do that, but I imagine that it could be done... Could save a LOT of work... more research!! Cool... Yes. Quite addictive...

Right now I'm trying to make a platform game, I have about half of the first scene. I just need to touch up the collisions, add enemies and the camera, I do everything manually without using the editor, which is something I haven't tried yet. I like doing it this way better.

I will 100% get into the board game when I finish the platform game, my idea is to make something similar to the checkers game and then with that base I can create other games with similar gameplay.

I am subscribed to a YouTube channel where there are many abstract board games with a base similar to checkers and since these games are not available for PC, it seemed like a good idea to design them myself.

I don't show a link because the channel is in Spanish.
Reply
#8
Platformers? The TileMap Editor is ideal for creating platformers but I am not that familiar with it.

I still use the old school method of creating a text-based "map". The game "reads" the map and "translates" each text character to the desired "tile" image. That's the fun part... the "real" work is coding movement, collisions, scores etc...

I tried using this method to create a clone of Mario brothers, which include "camera" movement, but that was a long time ago using sdlbasic. Not even sure if I still have it... (the game only had Mario moving across the game area - no enemies or collectables etc) - no promises... I will see if I can find it and try to reproduce it using N7 - assuming I can of course... lol

Looking forward to seeing your game. Gotta love platformers...
Logic is the beginning of wisdom.
Reply
#9
I'm going to share the code I've made because I'm at an impasse and I don't know how to continue.

I have three problems:

1-there is a cursor that moves around the board and if you stand on top of a player's piece and press "z" it picks it up and you can drop it on another square with the "x" key, but the problem is that it drops it anywhere box and I want it to only be able to be dropped in the dark boxes and I don't know how to do it.

2-when I grab a player token you can grab other player tokens at the same time and I only want it to grab one token at a time but I haven't been able to do it.

3-When I have a player token I should only be able to move one square per turn but it can be moved to any square, as could be done.


Attached Files
.zip   damas.zip (Size: 467.34 KB / Downloads: 6)
Reply
#10
(02-23-2024, 04:34 PM)aliensoldier Wrote: I'm going to share the code I've made because I'm at an impasse and I don't know how to continue.

I have three problems:

1-there is a cursor that moves around the board and if you stand on top of a player's piece and press "z" it picks it up and you can drop it on another square with the "x" key, but the problem is that it drops it anywhere box and I want it to only be able to be dropped in the dark boxes and I don't know how to do it.

2-when I grab a player token you can grab other player tokens at the same time and I only want it to grab one token at a time but I haven't been able to do it.

3-When I have a player token I should only be able to move one square per turn but it can be moved to any square, as could be done.

I made two posts but deleted them now, after looking up the rules of Checkers.

Hopefully this code can help you:

Code:
constant GRID = 8 ' number of rows and columns.
constant SQUARE = 53 ' size of each square.

set window "test", 640, 480
set redraw off

' create 8x8 array filled with zeroes.
board = fill(0, GRID, GRID)
' place pieces.
for y = 0 to 2  for x = 0 to GRID - 1
    if (y + x)%2 = 1  board[x][y] = 1
    if (GRID - 1 - y + x)%2 = 1  board[x][GRID - 1 - y] = 2
next
' center board in window.
boardX = (width(primary) - GRID*SQUARE)/2
boardY = (height(primary) - GRID*SQUARE)/2

' set to 1 or 2 when a piece has been picked up.
holdingPiece = 0
' original position of picked up piece.
originalPieceX = 0
originalPieceY = 0

' loop until user presses escape.
while not keydown(KEY_ESCAPE, true)
    ' check if mouse is inside board.
    mx = mousex()
    my = mousey()
    gridX = mx - boardX
    gridY = my - boardY
    if gridX >= 0 and gridX < GRID*SQUARE and gridY >= 0 and gridY < GRID*SQUARE
        ' convert to grid coordinates.
        gridX = int(gridX/SQUARE)
        gridY = int(gridY/SQUARE)
        ' click?
        if mousebutton(0, true)
            ' not holding a piece?
            if not holdingPiece
                ' any piece at that position?
                if board[gridX][gridY]
                    ' store information about the piece.
                    holdingPiece = board[gridX][gridY]
                    originalPieceX = gridX
                    originalPieceY = gridY
                    ' remove piece from board.
                    board[gridX][gridY] = 0
                endif
            ' already holding piece.
            else
                ' spot empty?
                if not board[gridX][gridY]
                    ' same position or valid distance for move? here both players can move up and
                    ' down. only "kings" should be able to do that.
                    dx = |gridX - originalPieceX|
                    dy = |gridY - originalPieceY|
                    if dx = 0 and dy = 0 or dx = 1 and dy = 1
                        ' put piece down.
                        board[gridX][gridY] = holdingPiece
                        holdingPiece = 0
                    endif
                endif
            endif
        endif
    endif

    ' draw.
    set color 0, 0, 0
    cls
       
    ' draw board.
    for y = 0 to GRID - 1
        for x = 0 to GRID - 1
            ' this formula gives a chess pattern.
            if (y + x)%2  set color 64, 64, 64
            else  set color 208, 208, 208
            draw rect boardX + x*SQUARE, boardY + y*SQUARE, SQUARE, SQUARE, true
            ' any piece?
            if board[x][y]
                DrawPiece(board[x][y], boardX + (x + 0.5)*SQUARE, boardY + (y + 0.5)*SQUARE)
            endif
        next
    next
   
    ' Draw picked up piece.
    if holdingPiece  DrawPiece(holdingPiece, mx, my)
   
    redraw
    fwait 60
wend

function DrawPiece(player, x, y)
    if player = 1  set color 240, 240, 240
    else  set color 32, 32, 32
    draw ellipse x, y, SQUARE/2 - 4, SQUARE/2 - 4, true
    set color 0, 0, 0
    draw ellipse x, y, SQUARE/2 - 4, SQUARE/2 - 4, false
endfunc

As it is now, both players can always move backwards or forwards diagonally. But according to the rules, only "kings" can move backwards. board[x][y] is now either: 0 = empty, 1 = player 1 piece or 2 = player 2 piece. I guess you can simply add two more values: 3 = player 1 king piece and 4 = player 2 king piece, and make it so that only kings can move backwards.

Edit And I'm sorry for not basing my code on yours. I'm just showing you how I would do it myself, and hopefully it can help you modify your own code Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)