Jump to content
  • Advertisement

DarkZlayer

Member
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

124 Neutral

About DarkZlayer

  • Rank
    Member
  1. I don't know a lot about cross browser compatability, but one thing you should do to help ease the pain is to have each browser just pass in their respective x,y into functions that actually handle it: Instead of duplicating code do this: function FirefoxMouseMove(e) { HandleMouseMove(e.pageX, e.pageY); } function ChromeMouseMove(e){ HandleMouseMove(e.clientX, e.clientY); } function HandleMouseMove(x,y) { document.getElementById("x").innerHTML="clientX: "+x; document.getElementById("y").innerHTML="clientY: "+y; } Sorry I cannot help more than that, but hopefully it's better than nothing..
  2. Heres a couple quick things I noticed skimming over it: 1. You can actually have setters and getters, instead of setName(). In the prototype of an object you can do this: Parent.prototype={ get Name() { return this.name; }, set Name( val ) { this.name = val; } } then you can call get an set the name with parent.Name or set it with parent.Name = "asdf"; You can also call the parent prototypes constructor with: Parent.call(this, -arguments-); inside of the childs constructor. Not really required, but can make it easier to follow along.
  3. DarkZlayer

    Scan room while wandering

    IF you can do each separately then combining them is simply a matter of calling the functions... Also, how do you use a point to represent direction? Could you post your code?
  4. This is an interesting problem, and without mapping out -all- the possibilities you like there is no clear cut way to go about doing this. Naturally the first thing I thought of though would be something like this. I'm certainly not proficient in PHP, so I don't know standards, but I have an idea of how to make it work without a very deep switch statement or a db (I think). I'll be building off of purely what you've given in your example to help keep this (hopefully) reasonably short Assuming the action comes as one thing from a single input split it into an array based on a space. $verb = $word1; // simply to get a more readable name $verbFile = "/verb/" . $verb . ".php"; if(file_exists( $verbFile ) { // have an individual object for each verb since they need to know how to act require_once( $verbFile ); }else { die( "Invalid Verb" ); //probably should fail more gracefully } Take out the need for a switch statement, if there isn't a file for the verb, assume it's useless. Lets now define a verb, and an Action interface. interface Action{ public bool Can( $word ); } All verbs must be able to tell what it 'Can' do. We'll pass in '$word2' into here to judge if it's capable. abstract class Verb implements Action{ protected $action; protected $objects; protected $preposition; public bool Can( $word ) { foreach( $i in $action ) { if( $word === $action ) { return true; } } foreach( $i in $object ) { if( $word === $object ) { return true; } } foreach( $i in $preposition ) { if( $word === $preposition ) { return true; } } } } So each verb now has the knowledge of which actions it can perform within itself. There is no reason anything else needs this globally available (like the switch statement would do). How can we now implements each individual verb to handle accordingly though.. In your switch statement all the words like 'exit', 'enter', 'crawl', etc can all perform simply actions, so we should have a class which each of these words inherit from also. For the sake of time I'll call it 'Movement' (even though 'exit' techincally fills this description, and doesn't have the same actions available so think of a better name ) class Movement extends Verb { protected $action; protected $objects; protected $preposition = array('above', 'across', 'after', 'near'); //all the other things in the switch statement public void Can( $word ) { if( parent::__Can( $word ) ) { // Any thing all verbs can do should be checked first (although I don't think there is anything..) return true; } //now loop through each '$action', '$objects', '$preposition' like 'Verb' does to make sure this specific Verb cannot do something an simple verb can do } } Now each verb that can do all the things in the preposition should be inherited from 'Movement', and now they can also have their own special cases. Lets say for example only 'Crawl' can do something like "CRAWL IN HOLE" (makes splitting the string more complicated, but makes for an easier example). class Crawl extends Movement { protected $action = array( 'in hole'; protected $objects; protected $prepositions; public bool Can( $word ) { if( parent::__Can( $word ) ) { return true; } // loop through possibilities for crawl specifically like the past 2 examples } } Anyway, I hope that gives a basic idea of how to go about that. Simply make generic classes, and slowly build up into more specific verbs which have their own specific cases. Now they code to check if something is possible can be represented as: $verbObj = new $verb(); if( $verbObj->Can( $word2 ) ) { // Probably should add a method 'Do()' into the Action interface so you can now do $verbObj->Do( $word2, $allWords ); //$allWords represents any word after the verb, and $word2 in the query }else{ die( "Invalid action for " . $verb . "." ); // fail more gracefully } Now you have a verb passing on responsibility to individual verb objects which can now know exactly what they are capable of without you having to build up a huge switch statement. Granted now you have to do something similar in order for '$verb->Do( $word2, $allWords );' in order for the proceeding words to now be able to take action based on that. I typed type all of this up purely in the forum so the chances of it being 100% correct are about 0%, but hopefully it gives you an idea of how to approach this. Also hope it didn't turn into a bunch of rambling. Edit: In some way you eventually have to check individual cases, but an OOP approach helps break it down into much more manageable pieces. For example if you decided that 'exit', 'walk', 'run', etc all should be able to do something new instead of wandering through the switch statement you can now just add the new action into "Movement", because you know all of those are movements. Or if you decide a certain movement needs it's own special case you can easily add it to it's own class also. Overall this is a more manageable approach, but doesn't eliminate the need to check if a verb can do a specific thing.
  5. Could you post the code? It's really hard to help without any example of your code.
  6. DarkZlayer

    GUI Button - Handling Each Event

    I'm sorry, I must have not made my question clear enough. I meant that, I'm not sure how to go about each event after it is clicked. I'll make a quick example: Button button1 = new Button(); Button button2 = new Button(); if(button1.isClicked()){ //Turn background red }else if(button2.isClicked()){ //Turn background blue } So, I was wondering if there is any way to hold what each button does from within the method. If I hold all the buttons for the window in an a collection like a list it'd be nice to just do something like: for(int ndX = 0; ndX < buttonList.length; ndX++){ if(buttonList[ndX].isClicked()) buttonList[ndX].doEvent(); } I'd prefer not to have a bunch of if statements like above for each and every button\textbox. The only problem is I cannot think of any other way (maybe because it's not possible?) to go about doing it than a bunch of if else statements.
  7. I'm just fooling around on making a GUI (that I will probably use in games later) and I'm wondering what type of approach is "best" for my situation. I'm going to have a Window and\or Panel object which will contain a collection of buttons and textboxs. It will then cycle through the collections to see if any has been clicked and then take the appropriate action. It's easy to handle whether or not if the button has been clicked but I cannot think of a good approach to "define" what each button does without having a whole bunch of: if(button1.isClicked()){ Do Action }else if(button2.isClicked()){ Do a different action } Ect. for every button. Perhaps this is one of the better\only ways to go about it or maybe I will have to redesign the Button class. Nevertheless, any help would definitely be appreciated.
  8. DarkZlayer

    Nooooob! Wants to make an RPG

    Quote:Original post by Zero The 1ne Sorry about the double text, it didn't go through the first time. Ok , now , The reason I call myself a noob that needs guidance is because 1) I haven't had much experience with the designs of rpgs. 1a) I have played much of FFVI and FFX, so I know how much of the battle system plays out 1b) I don't create graphics, actually my friend puts in the codes for images, i just place where to call them in, and use the pointers and addresses for them. 1c)I don't care whether or not you ***holes are in college or whatever. And if you feel like bragging about how much experience you have, why don't you get off your fat *** and go get a job, earn some money, build a company, and go make some "great" games. I hate it how you guys keep saying $#i+ like "Don't go into making games, I'm a ___major in college and since you aren't, i advise you shouldn't make games. I don't think anyone has said NOT to make a game. People have advised you to start on a smaller project first in order to figure out how to design (what you say you need help with!) RPGs. If you don't understand how to design it then frankly you either: A. Won't get much done without constant asking of the 'tutor' B. Constantly refactoring. You really do need to start out on smaller projects before you pursue this or it will just be a big project of disapointment. Either start out on smaller projects or use something like RPG Maker (like another mentioned) or Game Maker. Also, no one has even in the least bit bragged about being in college\professional developer. It was mentioned so that hopefully you'd type atleast a little bit more coherently.
  9. I could be looking at this wrong but all you should need is: pos += speed*dt speed: You can eliminate direction by just negating this value whenever it hits a wall dt: time since last update Why wouldn't that work for this situation?
  10. DarkZlayer

    Getting back into C#

    Frankly, I never completely understood OOP until talking to other (better) programmers about it. While I could just be an exception I found it hard for a book to really give me a good idea what OOP really is. I understood the basics of it but really understanding it came down to testing on my own, and (imo) more important talking to other programmers.
  11. DarkZlayer

    xna resizing question

    Well, depending on what you mean this could be a way to go about doing it. Have to variables like: int imageHeight = 800; int imageWidth = 600; Then for the keypress: if(Up Arrow Pressed){ imageHeight--; }else if(Down Arrow Pressed){ imageHeight++; } And so on. Then to draw it you'd do: spriteBatch.Draw(image, new Rectangle(x,y, imageWidth, imageHeight), Color.White); I think that is what you mean. If not just let me know. Or if you need the keyboard input in XNA explained.
  12. DarkZlayer

    Cheat prevention - how far to go?

    To reduce most of the stress on the server first check on the client if that move is possible. After that then you can then send a request to the server if that move is possible. The server would also check if that move is possible and then report back. While people could still edit the client to send the request still, this method will easily eliminate most of these requests to the server. And even if a person does edit the client to send it, it still will not effect the game since the server still does a check. Since most people will not know how to edit the client you shouldn't have to worry.
  13. DarkZlayer

    UDP help

    I still fairly new to networking so take what I say with a grain of salt. Quote:Is there any way to do a server->client send using UDP? -Yes Quote:I am using TCP for all my networking at present, but would like to shift some frequent message types to UDP. I've seen examples where a UDP server replies to a client request, but since UDP is connectionless, I am not sure the server can initiate a message. -No the server cannot make first contact with the client. Quote:How about if the client has first made contact with the UDP server? -With UDP the client must first make contact with the server. The way they 'talk' to each other is by sending each message to a certain IP address. Quote:Can the server keep the UDP connection open then? - Well, like you stated it is a connectionless communication. If you want to have the server send stuff to the client without it only being a response to a message the client sends you must store it's IP address. You mention that you want to change some frequent messages to UDP. Is it important for the messages to arrive at all? A downfall of UDP is that it doesn't check if the packets have arrived in order, or if they have arrived at all like TCP. You can make UDP act like it with the use of ACK's.
  14. Recently I started to fool around with online programming for games (or heck anything :P) and I'm just curious if I am going about packets the right way. So the example I will use will be an online game of pong. I can get it to work but it seems like there is a better way (I am too much of a perfectionist!) so I'd like some input. So let's say the up arrow and down arrow moves your paddle. Lets say one player presses the up arrow. I send a packet that does what you'd think it does: "Up" - Just for simplicity at this point I would send that. The server then goes throw a list of possible 'tags' the message can have and handles it accordingly. It will then send back a message to both clients telling it to update the position of one of the paddles. Truthfully I cannot think of any other type to do it (without a similar process) but having to tag each message and sending it to the server which has to search through code on how to handle it. I'm most likely just trying over-complicate this and if that's so, just tell me.
  15. DarkZlayer

    Tile map based collision detection question

    An easy way would be to use your characters x and y coordinates and turning them into an index in the array. I'll explain what I mean. Lets say that every tile is 32x32 so if your character was at an X position of 64 and a y position of 32 then he would have the index of [2,1] in the array. You would get this position by dividing the x and y coordinates of your character by the size of the tile. Then you could have a method to check if the spot your character will be moving to is a spot that doesn't have the value of 1. So you check for the key press and then before you move your character check the spot in the array that the character will move for a value. If that value doesn't equal one then you can move there. Does that make sense?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!