|
Answer» ok i am back and working on a... rougelike in c++! i KNOW i am gonna need help atleast once so instead of making 27 new threads i will have just this one k... i will be using conio for input and also for good old gotoxy (sorta reminds me of qbasic)) and colours, i am using BCC55 for my compiler and unfourently windows vista...
ok queeestioooonn nuuuumber 1: not really a question but can you guys give me some ideas for random dungeon creation?
thought of another(well didnt i had a problem) how would i do collision detection? i have thought about it but the only solution i can think of is to make the floors as arrays then then when moving do a caculation to see where you are located in the array and then when you move tests if where you are is a wall and if so backup and so on so yeah...those are the hardf questions do evreything in large multi dem arrays p.s. whats with your codename? it burns when i pee hehehethanks and i dont know a friend was watching xplay i think and i heard them say that then the DAY after i regestired here so yeah lolyou create a type that descripes your object and then crate an array of those objects such as Code: [Select]typedef mytype { int x,y; UNSIGNED char color }; mytype a[100]; a[0].x = 10; a[0].y = 10; a[0].color = 1; just an ideaok i have been tring to deal with this for a while, basically this is what happens when i press up i go left and down i go right, then when i press left or right it makes me jump, other then that no real problems, and i cant figure it out with te debugger... here is the code so far, very very sloppy... Code: [Select]#include <iostream> #include <string> #include <stdlib.h> #include <stdio.h> #include <conio.h>
using namespace std;
string INPT; //used for getting input string map[82][24]; //the map int fx; //future x int fy; //future y int x; //x int y; //y int px; //previous x int py; //previous y int hp; int str; int dex; int def; int loop; //used in while loop string it; //used for storing tile on preveiosly string nit; //next it string test; //used for collision testing
void mapinit() // gives a value to the map { for (int nx = 1; nx < 81; nx++) { for (int ny = 1; ny < 23; ny++){ map[nx][ny] = "."; }; }; }
void prnt() // used for printing map { gotoxy(1, 1); for (int nx = 1; nx < 81; nx++) { for (int ny = 1; ny < 23; ny++){ cout << map[nx][ny]; }; }; }
int main() { it = "."; // sets it mapinit(); loop = 1; map[22][22] = "#"; //# = wall x = 21; y = 22; fx = x; fy = y; px = x--; py = y; while (loop == 1) { map[x][y] = "@"; // displays dude map[px][py] = it; // covers up where you walked before system("CLS"); prnt(); it = nit; inpt = getch(); //gets input if (inpt == "H") { //up fy--; } else if (inpt == "P") { //down fy++; } else if (inpt == "K") { //left fx--; } else if (inpt == "M") { //right fx++; } test = map[fx][fy]; //tests where you are attempting to go if (test == "#") { fx = x; fy = y; } if (test == ".") { nit = "."; } px = x; py = y; x = fx; y = fy; }; return(0); }the code is fairly sound but why are you using the map of type (class) string because that should make it a triple demitinoal array and that is just wasting memory try char map[82][24]; also for sprite colisions try just searching one tick ahead on the map
|