C++ :: 2D Tile Map Saver / Loader
Nov 13, 2014
I am creating a 2d tile map game currently and I am trying to find a moderate way of saving and loading it through a text file and fstream.h. I am doing the saving by integers as well. What is difficult for me to understand is how integers save and load. Per line perhaps? I am just not sure about this.
View 3 Replies
Jun 14, 2013
So I have the following code using [URL] ..... It compiles correctly, but does not display the map on the screen. Is it an issue with my code or an issue with the map file itself?
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <level.h>
int main(){
sf::RenderWindow window(sf::VideoMode(640, 480), "");
[Code] ....
View 1 Replies
View Related
Mar 26, 2014
how to replace tiles within a map. My map data is in a .map file and I'm wondering how I can manipulate it to change the tiles.For example, If i kill an enemy, I would want his sprite to go away. I need to know how to do this. I also need to know how to have collisions work. At the moment I have a system where it checks if the tile in a certain direction (based on whatever arrow-key I press) is a certain tile by using its variable name TILE_TILENAME. I'm likely not doing this right, as collisions do not work, but the game still runs fine.
Here is some of my code;
//The tile
class Tile
{
private:
//The attributes of the tile
[Code]....
View 1 Replies
View Related
Aug 15, 2014
Im supose to use <>bool removeTile(char, int, int, char[])<> to do this "function that takes in the choice (D or S) and the two dice numbers and the board as input arguments. When the move is legal and the tile is available for removal, it removes the tile according to the choice by marking the tile as ‘X’. Returns true if the move is successful."
View 4 Replies
View Related
Apr 10, 2013
I have been writing a fairly simple turn based rpg game in c++ and at the moment it has a 2d integer array for the map, which I can display using periods for the blank areas and letters for the various people in the game, and I am trying to figure out how to upgrade to a tile based display.
View 3 Replies
View Related
Oct 14, 2014
I'm still working on my Project and the next Problem has occured: How do I detect collisions on a tilebased map? My tiles are 16x16 and the map is based on the tutorial of [URL] ..... I really like this Approach because I can define for each tile of what type it should be (so a earth tile can be walkable and lead to a secret passage).
The first Number stands for what Kind of tile it should be (e.g. Grass, Earth, Water, Blank,...) and the number after ":" stands for the type of the tile (e.g. solid, walkable, do dmg to the Player,...).
e.g.
0:0 0:0 0:0 0:0 0:0 //No tile and walkable
0:0 0:0 0:0 0:0 0:0
0:0 0:0 0:0 0:0 0:0
1:1 1:1 1:1 1:1 1:1 //Grass tile and solid
2:1 2:1 2:1 2:1 2:1 //Earth tile and solid
It's working just fine with loading the Images, but i've got no clue about the collision. I've already read a lot of stuff on the Internet but I don't get how to Combine it the structure from above. For example lazyfoo describes the collision with one object like one wall. So how can I check the Player Position with each tile?
For now there's no camera, but I plan to implement one later...
I'm trying to make a 2D platformer
View 5 Replies
View Related
Jul 10, 2013
Basically I have an tile class with the following variables: x, y, texture, and solid. I have created an array called tile MAP[map_tiles_x][map_tiles_y]. The object of the following snip-it of code is to loop through all of the tiles in the map placing their default values in each. For some reason this code does not work as planned, but in theory shouldn't it? I cannot see why it doesn't work. (BTW I do plan on open sourcing this map editor.
void init_map(){
for (int tile_y; tile_y < map_tiles_y; tile_y++){
for (int tile_x; tile_x < map_tiles_x; tile_x++){
MAP[tile_x][tile_y].x = tile_x * tile_size;
MAP[tile_x][tile_y].y = tile_y * tile_size;
MAP[tile_x][tile_y].solid = false;
std::cout << MAP[tile_x][tile_y].x << ", " << MAP[tile_x][tile_y].y;
} }
I should also add the effect of the code. Basically it only sets the default coordinates for the first object :/.
View 4 Replies
View Related
Mar 14, 2015
I've got myself a 2d array
int[,] map = new int[100,100];
I've populate that will a bunch of 1's and 0's. The 1 represents a wall, and a 0 is dirt.
I'm looking for a way to clean up my blank spaces outside of my walls. Any algorithm I can use to identify these big areas and replace them with a '1'
for (int y = 1; y < map.GetLength(1) - 1; y++) {
for (int x = 1; x < map.GetLength(0) - 1; x++) {
// Inside here is where I was hoping to archive my work
bool draw = true;
foreach (Room room in rooms)
[Code] ....
Attached is an example of my output.As you will be able to see, there is a lot of brown. I want to fill the brown with walls, but leave space for a path between the rooms.The 'draw' bool is true when I'm outside of a room, just so I don't start throwing walls inside my room.
Example of what the array would look like (for those who don't know)
int[,] map = new int[100,100]
{
{0,1,1,1,1,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,1,1,1,1,0},
};
View 6 Replies
View Related
Aug 27, 2013
I should reduce the number of bitmaps I used in my code. I translated my particle engine into code that could be compiled as plain standard C
Currently, the code has a segmentation fault somewhere that I can't figure out. How it should function is that it takes orders from a queue for new lasers to store the instances in a linked list. It then takes that data and updates its coordinates, one node at a time. The first node should also be the first node to complete its life, so it gets removed, and the list is set to the next node in memory. If there are no more nodes left, a if-statement should catch it and either break the current loop, or wait for more items to be requested. If there are nodes left, the process will continue to remove the first node in the list until there are none left. Obviously this is not quite how it works. When I tested in once in SDL, the laser would update every 5 frames, but wasn't shown constantly, and would crash after the node was to be disposed of. When I initialize with the SDL parachute, it would exit before I event saw the screen. Also, the code I translated to standard C will display that the laser has been updated to the screen, but it never says that it has moved up. It crashes after about 4 printf() statments execute. My debugger has been giving me mixed SIGTRAPS, and "nothing is wrong" output. Here is the code in standard C:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_LASER_QUEUE 10
}
[code]....
View 6 Replies
View Related
Nov 7, 2013
So I tried to make a tile map function to display my map as tiles. I keep getting unresolved external symbol errors, I've included the header file, and used every declaration in it, but to be completely honest this is mostly just a try to see if I could do it, and so far I'm failing. So if you can see why I'm getting the error.
header tileMap.h:
#include<SFML/Graphics.hpp>
#include<iostream>
#include<fstream>
#include<string>
#include<cctype>
#include<vector>
class tileMap{
[Code] .....
output message:
1234567891011121314
1
1> main.cpp
1>c:users wiggystardustdocumentsvisual studio 2010projects ilemapenginemain.cpp(21): warning C4018: '<' : signed/unsigned mismatch
[Code] ....
View 8 Replies
View Related
Mar 13, 2014
I'm making a simple tile-based RPG and I've run into a bit of trouble when I put my code into classes.
Heres my main
#include <iostream>
#include "windows.h"
#include "math.h"
#include "time.h"
#include <string>
#include "Goblin.h"
#include "User.h"
#include "Inventory.h"
#include "Maps.h"
using namespace std;
void treasureGet();
[Code] ....
My other 3 classes have the same structure and the same error for all their functions.
This is the exact Error
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Inventory::inventoryOpen()'|
undefined reference to `Goblin::Goblin()'|
undefined reference to `User::User()'|
undefined reference to `Inventory::Inventory()'|
undefined reference to `Maps::Maps()'|
||=== Build finished: 9 errors, 29 warnings (0 minutes, 0 seconds) ===|
View 4 Replies
View Related
Jun 6, 2013
void create_map(){
int x = 0;
int y = 0;
while (y >= 15) {
game_map[x][y].pos_x = x * tile_size;
game_map[x][y].pos_y = y * tile_size;
Objective of the code: to loop through all tiles in the game, setting their X and Y coordinates.
It just doesn't do anything at all. No error message.
View 12 Replies
View Related