Jump to content

  • Log In with Google      Sign In   
  • Create Account


Need Help With rogue-like problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 miradosamurai   Members   -  Reputation: 112

Like
0Likes
Like

Posted 23 April 2013 - 02:35 PM

hey guys i am working on a rogue like game and i have quickly hit a problem ,which is i don't know how to make a wall in the game that the player can't walk through i have got boundaries set up but that's it and if you didn't notice the tag im coding in C#.by the way if your thinking i should know this code like the back of my hand im mainly working on this as a learning thing so please don't be rude.

 

actually its not going to be turn based the enemies/npcs are going to move whether you do or not. and like i said i am doing this to learn so i don't know how to do that paradigm.


Edited by miradosamurai, 23 April 2013 - 03:20 PM.


Sponsor:

#2 Paradigm Shifter   Crossbones+   -  Reputation: 5230

Like
1Likes
Like

Posted 23 April 2013 - 02:43 PM

Tile based, moving 1 square at a time, like Rogue or Nethack? That's easy, store the player position before a move, move the player to the new tile, if it is blocked remember what the player hit (walking into a wall may print ouch, moving into a monster may attack, etc.), and move the player back to the old position.

 

It may be easier to code if you have dummy tiles surrounding the map which are always blocked so you don't need special cases for preventing the player from moving off the edge of the map.


Edited by Paradigm Shifter, 23 April 2013 - 02:48 PM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#3 miradosamurai   Members   -  Reputation: 112

Like
-3Likes
Like

Posted 25 April 2013 - 01:59 PM

like i said i am doing this to learn and i don't know how to do that and no its not going to be 1 square at a time.



#4 warnexus   Prime Members   -  Reputation: 1396

Like
0Likes
Like

Posted 25 April 2013 - 03:27 PM

like i said i am doing this to learn and i don't know how to do that and no its not going to be 1 square at a time.

you can use a 2-d array given miradosamurai's advice.



#5 Khaiy   Crossbones+   -  Reputation: 1342

Like
1Likes
Like

Posted 25 April 2013 - 07:50 PM

like i said i am doing this to learn and i don't know how to do that and no its not going to be 1 square at a time.

 

I don't understand what you mean. Paradigm Shifter's post tells you how to do "that", and it does everything your initial post suggests you need. If it is inadequate for what you're trying to achieve, please explain how so (if movement isn't one square at a time, how does it work?). If you don't understand something that is posted, ask for more information. Is there a specific piece of Shifter's post you don't understand?

 

Posting more information about what you've already got will be helpful also. What constitutes a "player", "enemy", "wall", or "boundary" in your code as you've currently designed it?

 

by the way if your thinking i should know this code like the back of my hand im mainly working on this as a learning thing so please don't be rude.

 

Try to avoid being rude yourself. Even if you don't mean to sound harsh or ungrateful, a poorly chosen word or phrase that sounds like you are can dramatically reduce the number of replies you get. Bear in mind that you're asking people to help you, for free, and in their spare time. I've always found people here extremely helpful, regardless of the question asked, as long as it is asked nicely and with a bit of humility.



#6 miradosamurai   Members   -  Reputation: 112

Like
0Likes
Like

Posted 25 April 2013 - 09:45 PM

sorry i wasn't meaning to be rude, also i miss read Paradigm Shifters reply and i though he meant turn based; also like i said i am doing this as a learning experience so i am a noob or whatever you want to call me , i do not understand c# 100% and i do not know how to do most of the things on this website. 



#7 Khaiy   Crossbones+   -  Reputation: 1342

Like
0Likes
Like

Posted 25 April 2013 - 11:14 PM

Shifter's post is language-agnostic. It suggests a couple of data structures and functions but leaves implementation abstract.

 

What Shifter described is basically this:

 

Say you have a map which is represented as a 2D array, as in warnexus's post. Anything on the map (a character, monster, wall, whatever) has a current position represented as a point on that map. So the player character might be at position (5, 6), where 5 is the x coordinate and 6 the y. If the player wants to move up one space (coordinate point (5, 7)) your game would update the player's position accordingly.

 

But if there's a wall at (5, 7) you won't want the player to be able to move there. So in the function you're using to move the player character you would first check to see if moving from (5, 6) to (5, 7) is valid. If it is, meaning that the space is open and the player can move there, then you would allow the function to update the player's location to (5, 7). If it's not valid, meaning that (5, 7) is blocked for whatever reason, then the function will not allow the player's location to (5, 7) but rather will remain (5, 6).

 

How exactly this will be implemented in your code depends on how you've designed it, which we can't know unless you give us some more information. How you're handling time (turn-based, real-time, whatever) doesn't really matter; you would perform the check as often as is necessary, whether that's by turn, per tick, per second, per hour, per movement attempt.

 

Unless and until you give us more information on what code you've already written or how you've designed things so far no one will be able to give you much more than general advice. I can't tell you how to implement this in C#, not because neither of us knows C# well enough but because there's no one "C#" way to do it. The language is about rules for how code is written, it doesn't enforce many design constraints on you. Language makes zero difference at all in designing these features into your game. So again, I'll request that you present some code to us, or some design decisions you've made, or ask some more specific questions, or ask for more specific clarifications.



#8 miradosamurai   Members   -  Reputation: 112

Like
0Likes
Like

Posted 26 April 2013 - 12:37 PM

i have loosely followed this tutorial (http://www.youtube.com/playlist?list=PLB062D4D37FECD5A6) to the second episode most of the stuff in my code is the same as his though same movement and anti-flickering etc not much difference same ype of map style as his but mine is bigger and a small room in the middle different character symbol more health different name and no mana.



#9 Khaiy   Crossbones+   -  Reputation: 1342

Like
0Likes
Like

Posted 26 April 2013 - 09:11 PM

I took a brief look at the video you linked to. Is this tutorial the only exposure you have to programming, in C# or otherwise?

 

How well can you explain your code which, as you said is mostly a copy of the tutorial's? Can you describe the flow of the program as it executes, how the functions work, how data related to gameplay concepts (such as player location) is represented, or might be represented in the future, in the code?

 

It's not bad to use tutorials when learning how to program new types of projects, but no number of tutorials can substitute for learning a programming language or gaining experience in program design. "How to program X type of game" is my least favorite type of programming tutorial. Most of the time they aren't even wrong, but they tend to produce bad programming habits (particularly related to design and debugging) and hollow coders who may have a game to show but not much independent programming ability. I'm not saying that that describes you, just that tutorials like this one should not be a major piece of your programming education. Particularly if you're just starting out.



#10 miradosamurai   Members   -  Reputation: 112

Like
0Likes
Like

Posted 27 April 2013 - 12:37 AM

thsnk you all


Edited by miradosamurai, 27 April 2013 - 10:05 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS