There was a game that I made a ways back when I was taking JavaScript Programming in college 20 years ago. I was thinking the other day of porting that by rewriting it for C++ from scratch to be a stand alone game that runs on C++ and ran into the challenges of graphics. So I remember in one of my old Borland C++ books it had bitmap rendering and all sorts of stuff on bitmaps.
So I skipped over looking this up in my old book from the late 1990s and went on to make the 120 different game states as 120 differently named bitmaps in Microsoft Paint. The idea is to call to the bitmap that displays the game state to display that game state without having to specify every bitmap pixel or sprite location, just call to the image and display the image that shows the game state which I thought would make it way simple than having to piece together pixels.
My book is somewhere, possibly lost in the move, and searching google I dont see any exact matches to what i am trying to do and they all seem to call to an outside viewer to display the image which for a game to have a viewer instance called, the only way that that could work for this game is if there was a refresh loop that was looking at a target location and display any bitmap at that location so as the game changes the viewer changes the image result of whatever the player is doing. Additionally there is the problem with the fact that you now have 2 windows open. One that displays the image for the game state and the other for the user input.
I'd like to get this all into the same window vs calling to outside viewer and its looking like I need to do away with console C++ programming and switch to programming for Windows. However once again I hit a wall looking for code examples to learn from to piece together my program to make this work.
The game title was Dark Room Deathmatch, the concept of 2 or more players placed into a dark confined space room with a knife and only 1 player survives, and they can not hear or see each other as they are all quiet in moving but when they bump into someone they stab them and then get to flea so who they are attacking cant just target the same location they are at. It starts off where you can't see your opponent initially. And after a certain number of moves the room shrinks in space by blocks in strategic areas no longer in play and so they get greyed out, and if a player is located at one of these blocks that is no longer in play they get relocated to the nearest block that is still in play. As the game progresses further if someone hasnt died yet then hint of blood is enabled and so you have an idea of where your opponent is sort of like hot or cold hot for closer to opponent and cold for further away but it doesnt give exact location away it makes blocks glow pink around a player but the player might not necessarily be at the center of the glowing blocked area they could be located on the edge of the glowing pink blocks. I also added special moves to the game that allowed players to teleport themselves to any block that is still in play but it was a limited use feature. If someone felt like they were being cornered they could use it to jump to far end of map or any location still in play. This feature of teleporting though wasnt enabled until a certain number of moves so that someone couldnt use it as their opening move to exploit the person going first landing on the starting location of their opponent which is known at the start.
Because I am not an artist by any means I chose to go low tech with just a map that shows your location in relation to the play area. Its about as low tech as a board game with a piece that moves on the board. The game is a combination of other game concepts mashed together. For the fact that your playing in the game environment of in the dark there is no need to display anything that impressive other then a map with a block location to indicate where you are as well as any changes to the map.
With javascript for this game it was pretty easy as for the browser environment allowed for user input and a refresh of the image to show the change in the game state. An array was used to keep track of where the player was, and if the array value was 5 for the players location, the image for map5.bmp would display to reflect the location of the player in regards to the other player. The game was like battleship in that you didnt know where the other player was but that when you found them they could flea. So unlike battleship where once you hit the opponent you just need to determine the orientation of fixed objects, in my game the opponent can go in 8 different directions to flea in a 30 block area laid out as 2 blocks, 4 blocks, 6 blocks, 6 blocks, 6 blocks, 4 blocks, and 2 blocks with each player starting on opposite ends of the map. It starts out as an open area and no idea where each other is until you land on them to strike a hit. After so many plays in the game blocks in specific locations turn from white to grey as they are barriers that are placed into the game to make the odds of bumping into each other increased as there are lesser blocks to move to. Then as the game goes on for even more turns by each player blocks in an area will turn pink indicating that your enemy is near and so each person knows a hot or cold close or far away from each other to further increase the odds of each other striking each other by landing on the block that they are at. After a player is struck 10 times they are dead. This javascript game was single player because making it 2 or more players would have required a database and forms to pass the data to the database etc and web server side dynamic HTML etc and time was limited.
I was thinking if I could get this working with C++ ( or just about any other programming language out there ) that I can get the multiplayer aspect of this to work. The game would play on 2 computers that have access to a network share. The network share has text files for the game state information to be passed between the program running on each of the computers. One of the text files is a read/write lock which keeps control of Player #1 vs Player #2's turn. The game has a time delay loop in it that tests the value within the text file to see whos turn it is. If the value is 1 then its player 1's turn. If the value is 2 then its player 2's turn.
I was talking to a friend at this years game con and he suggested that I should bring the game there next year with 2 computers since I have plenty of spare working computers that I could leave set up for people to sit down and play against each other etc. Even though its a low tech game and no impressive graphics he said it sounds like it would make for some fun for people looking for a break from the other games.
If I can get it working as 2 player then my goal is to then make it 4 player turn based with a larger map. But not going to go that route until I can get the 2 player version of this hammered out and working.
the reason why i am not going with a database to keep track of game state is because its just a few players. Its never going to be a game that is large scale that you have multiple instances of it going on, and a network share to text files with game states is simplistic and I have used that method before in the past for 2 player card game that was C++ console based to play War with a network connected friend to a network share back in college.
Javascripts inability to read/write to files locally as designed due to security reasons is the main reason why i didnt just take what I had in javascript and make it 2 player.
Part of me is feeling a tug to go with dynamic HTML vs beating my head against the C++ wall and just make the game run off of an apache web server with php for example and go the database route for keeping track of game state and progress. This method would make use of the bitmap game states very simple to implement. But I havent caved to that just yet and am sort of determined on a way to pull this off with C++ and avoiding the use of a database and instead just text files that each computer uses to keep track of turn and game progress.
I looked for a C++ code example that has a button and displays one bitmap image and then click on that button and it displays a new image as for once I know how to achieve this I can replicate the code and add the logic guts to it to make the rest of it come together I feel.
Additionally I refuse to just go the route of displaying ASCII characters for a display for the user with a console window open and something that looks like this with X as the players location
[ ] [ ]
[ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ]
[X] [ ]
To show location of the player on a map with the slightly better than Zork method of gaming.
Seeing a picture vs ascii just looks more appealing and at least gives it an Atari 2600 feel of complexity which is more visually appealing.
Additionally I feel that I need to get over this roadblock and learn from it vs going an alternate route to achieve this unless its more realistic to go the route of the apache web server with people connecting to it with dynamic HTML, php, and form data passed to database to make it 2 to 4 players.
The up to 4 player version would be like this, but as a clean looking bitmap image in paint with some eye appeal and maybe a nice background too. Only the player themselves location is displayed to them. They cant see the other player or players. The numbers 1,2,3,4 indicating player start locations and all of then free to move in any direction and land on each other to land hits and able to move 1 or 2 places per turn or skip moving and stay put if foolish to wait to be landed on or stay out of the mix in the middle in hopes to wait it out around the outside perimeter until 2 players are eliminated and they can then focus on just 1 opponent as everyone went after each other towards the middle of the play area using the demolition derby method of staying out of the initial fight wih heavy damage to then wait it out to see who survives it and then go after them in hopefully better shape than they are in leaving the fight but taking some damage from others who failed.
[ ] [3]
[ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[2] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [4]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ]
[1] [ ]
Players health Bars can be displayed or not displayed by choice. If not displayed for actual health bar to be known by all then its just an alive or dead indication.