Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - phlip45

Pages: [1]
1
Programming / Re: Inventory and pop-ups: Who calls what?
« on: November 25, 2014, 10:24:16 PM »
That makes sense mcouk. I don't think my game has boiled down to a game state with just input, draw and render yet. It could be because Javascript is a bit weird in that it is asynchronous  so multiple functions could be executing at the same time instead of one thing has to finish before the next one begins. Right now timing is handled by a scheduling engine that just lets different actors take their turn. Each actor is responsible for updating its position on the game map and drawing itself when it is created. Currently it is the player objects responsibility to keep track of the inventory interface and other such windows because these things are only going to happen on the players turn.

It could also be because I'm dumb =P.

2
Programming / Re: Inventory and pop-ups: Who calls what?
« on: November 25, 2014, 02:33:06 AM »
Thanks Minotauros. I realize that it probably just seems difficult for me right now because it is the thing I'm working on currently. Things always tend to seem more difficult while you are working on them or just before. I still would be interested in what methods people have chosen to tackle this particular problem, as I'd just like to see the different ways people attack a problem which to me seems open to several solutions. Something described here may end up being more intuitive to me then my own line of thinking (which happens a lot to me).

3
Programming / Re: Inventory and pop-ups: Who calls what?
« on: November 24, 2014, 07:41:36 PM »
Sorry if the description was vague.

Right now my player has an inventory object that holds his inventory and the functions that add/remove/ or manipulate items in his inventory. I have it as its own separate object in case I want other actors like monsters or npcs to have their own inventories. Currently the functions that handle displaying the inventory window and item information is contained inside this inventory object.

What I'm thinking of doing is removing the display inventory and item information functions and placing them in a menu object that would later house all the functions that display all non-map windows. This way I can consolidate functions that would be useful for drawing and updating these screens.

I never thought of using an array to track where the user had come from and pushing/popping that information into/out of that array. It seems like a neat way to do it.

4
Programming / Inventory and pop-ups: Who calls what?
« on: November 24, 2014, 09:56:13 AM »
So I'm endeavoring to write a rogue-like game in javascript to learn the language a bit. I'm using the Rot.js library as a base and so far everything works pretty good. I keep wavering back and forth on how to implement the inventory screen though.

The way things are in my current implementation is that all key-presses start off handled by an event handling function. If the inventory button is pressed then a flag is set that the player is in the inventory and future key presses should be directed to an inventory object until that flag is no longer true. The key code is then handled there. So right now the Inventory object is handling outputting text to the screen and such.

What I think I might want to do however is have a Menu object that acts as an inbetween to handle all the outputting of text to the screen and receiving input and then calling on the inventory object to provide the data to display. I think this would help later on when I have more menus to work with, but I'm unsure which is going to be easier to maintain, having the menu object draw everything and take info from other objects or have objects handle their own menus.

There is probably another way of doing it that I do not know as I'm new to programming, so which of these methods do you use, or what methods are there of handling menus beside these two.

//sorry if this is not the correct place for this topic but I'm also new to this site

Pages: [1]