Jump to content
  • Advertisement

imontheverge7

Member
  • Content Count

    35
  • Joined

  • Last visited

Community Reputation

207 Neutral

About imontheverge7

  • Rank
    Member
  1. imontheverge7

    Open world 2d map loading

    Could you share some pseudo code about how you did that? I'm guessing you use the players world coordinates and either add or subtract from the loaded chunks based on what you need to load
  2. imontheverge7

    Open world 2d map loading

    My plan is to create a seamless open world 2d map using something like tiled for the maps. I'm using monogame so I'm sure they have some kind of tmx importer. My question is, if I have a map that is 1000x1000 tiles across, tiles being 32x32, would the best method be to load it in chunks of maybe 100x100? Or whatever fits the screen size I'm using. My first plan was to just load the whole map at startup but with npc data and random things like that, it could use a lot of memory.
  3. imontheverge7

    Inventory / item logic

    Alright so this is what I have so far. The items are going to need more parameters eventually, but I'll handle them with strings and integers in the constructor of each item. HashMap<String, Item> ItemList(); private static void Hoe(){ Item hoe = new Item(); hoe.itemName = "hoe"; ItemList.put(hoe.itemName, hoe); } Each of my item constructors will look like this, and then I populate the HashMap by calling the static method at the start of the game. putItem(Item.ItemList.get("seed"), 2); public void putItem(Item item, int itemQuantity){ for(int i = 0; i < playerInventory.length; i++){ if(playerInventory[i].itemName == item.itemName){ playerInventory[i].itemQuantity += itemQuantity; break; } else if(playerInventory[i].itemName == "empty") { playerInventory[i] = item; playerInventory[i].itemQuantity += itemQuantity; item.itemIndexInInventory = i; break; } } } This is how I add the item to my inventory. It works right now but as I add more parameters like different seed types and strength of tools, I'm sure ill need to change some things.
  4. imontheverge7

    Inventory / item logic

    Thats a good idea. Its always good to take a break from one piece of the project and move to the next
  5. imontheverge7

    Inventory / item logic

    I don't know if I want to take the time to learn another language and how to import it, or write a lot of methods. I prefer clean code though
  6. imontheverge7

    Inventory / item logic

    I think I get it. When I get onto my computer later I'll post some code and see if I have it right. I don't think the properties of my items will be changing much so I can keep it simple. Inventory = new Item(itemHashmap.getKey("seed"); But I'd still need to write the 100 different constructors to populate the itemHashmap or use XML.
  7. imontheverge7

    Inventory / item logic

    Normans post says to have an array that stores the info for the item and the item itself. Right now I only have the latter, but if I created a hashmap<Item, Integer> I won't need to constantly be creating instances of class Item? If I understand correctly
  8. imontheverge7

    Inventory / item logic

    I almost used a hashmap for my inventory thinking it would be better but I needed a way to get a specific item from the inventory. But my approach is like SirWeeble class Item itemName quantity public Item Seed(int quantity) ItemName = "seed" Quantity = quantity But if I have 100 items I'll have 100 different methods like the above method.
  9. imontheverge7

    Inventory / item logic

    Thats what I was thinking but I wouldn't know how to implement it. Pretty much each item is going to have multiple attributes associated with it like sell and buy price, if it's a tool, If it's edible etc. So if I created a base item class and inherit each item from it, that'd be a lot of code.
  10. imontheverge7

    Inventory / item logic

    I'm creating a harvest moon type game and currently working on my inventory and item system. I have a class InventoryHelper, which holds my inventory array and methods like putItem and removeItem. My array takes my class Item. My Item class holds a constructor which takes a string Name and int Quantity as an argument. Also in the class file, are static methods that create certain items like createSeed. All these methods do is set the name and quantity and then return Seed. The question is, am I going about this the right way? Eventually I'm going to end up with hundreds of different methods for creating different items which is probably not the best practice, but I am curious to know what other approaches I can take to this.
  11. imontheverge7

    libgdx screen issues

    I'm trying to make a jumper type game for android and I am having some trouble getting the screen to function correctly. I have a camera and a viewport but I dont think I'm using either of them properly.  camera = new OrthographicCamera(); viewport = new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); It's my understaing that Gdx.graphics.getWidth() gets the width of the screen resolution no matter what device it is on? camera.update(); game.batch.setProjectionMatrix(camera.combined); game.batch.begin(); This is in the draw method. When I draw my background at 0, 0 the picture starts doesnt cover all the screen and you can still see the background color.
  12. imontheverge7

    Design question: Managing multiple methods

    I'm trying to get into the habit of organizing my code before it becomes too cluttered and I can't find a method when I need it.    Player class: -Load, update, and draw -Remove and add items to inventory -Pick up, Craft,  and equip items -Get items from a tree and bush(should be in seperate class?)   Main class: -Load, update, and draw -check collision between map and player -check collision between solid objects and player -sets player variables nextToTree, nextToFire, nextToBush(separate class?) -3 methods for setting tinder in fire pit, lighting the fire, and adding logs to the fire(separate class?)   This is kinda the breakdown of what I have going on right now. I feel like some of these methods don't really fit in those 2 classes and I'm wondering how to organize this
  13. In my game, I have a bunch of methods which handles interactions between the player and objects within the world. The list of these methods is only going to grow as I move forward with the game. My question to you is this:   What is the best way to handle methods between the player and world? Currently I have them in my Player class and main game class and even at this point it looks sloppy and unorganized.   Player class contains interactions with inventory, and interactions between tree objects in the world. I don't know why I put the tree methods there but it seemed like the right place at the time. Main game class contains all collision detection methods, and methods for creating a fire. I think the collision detection methods should stay in this class, but there is no reason for the CreateFire methods to be in there.    Would I be better off creating a new class that holds all of these methods that handle interactions between the player and the world? I know in XNA you can create a Game Component type class which may work. public class InteractionHandler { //some variables here public InteractionHandler{} //empty constructor public void UpdateHandler(//some parameters here) //all methods that handle interactions } This is the idea I have in my head. I've never created a game of this size before so I don't really have an idea about how to organize this.
  14. imontheverge7

    2D lighting

    I am currently using this texture to draw lights around my items that emit light.     Now this works great so far for lighting objects, but I want to create a dynamic lighting system and draw it from the center of my object that emits light. The problem is that I have no idea how to do this. I'm not so much concerned about realistic lighting like flickering and things like that. For now I want to be able to resize the light area on the fly when it's needed. How would I go about doing this?
  15. imontheverge7

    Light from items

    Well I got a decent system down using this tutorial http://blog.josack.com/2011/08/my-first-2d-pixel-shaders-part-3.html. I am using the Ambient variable to just change the LightMask render target now and this works perfectly protected override void Draw(GameTime gameTime) { GraphicsDevice.SetRenderTarget(mainTarget); GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, camera.Transform); map.Draw(spriteBatch, Color.White); player.Draw(spriteBatch); foreach (Item item in QuadTreeItems) { item.DrawItem(spriteBatch, Color.White); } foreach (Tree tree in trees) { tree.DrawTree(spriteBatch, Color.White); } Rain.Draw(spriteBatch, Color.White); //TreeDrawer.Draw(spriteBatch); spriteBatch.End(); spriteBatch.Begin(); player.PlayerInventory.DrawInventory(spriteBatch); player.PlayerInventory.DrawInventoryItems(spriteBatch); player.PlayerInventory.DrawInventoryNumber(spriteBatch, font); player.PlayerCraftingSystem.DrawCraftingTable(spriteBatch, player, font); foreach (Item item in player.PlayerInventory.Items) { if (item.ItemSlotRectangle.Contains(MousePosition) && item.ItemName != "empty") { spriteBatch.DrawString(font, item.ItemDescription, new Vector2(item.ItemSlotPosition.X, item.ItemSlotPosition.Y - 20), Color.Black); } } spriteBatch.End(); GraphicsDevice.SetRenderTarget(lightTarget); GraphicsDevice.Clear(daylight.GetDaylightColor(daylight.Ambient)); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, camera.Transform); foreach (Item item in QuadTreeItems) { if (item.EmitsLight == true) { spriteBatch.Draw(light, item.Position, Color.White); } } spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); lightEffect.Parameters["light"].SetValue(lightTarget); lightEffect.CurrentTechnique.Passes[0].Apply(); spriteBatch.Draw(mainTarget, Vector2.Zero, Color.White); spriteBatch.End(); base.Draw(gameTime); } I was surprised at how easy that was!! and the effect file isn't too hard to understand. The next step is getting the light around the object to fade in and out a little to better simulate a fire. I don't have a fire Item yet so my rocks are emitting the light right now  I think I need a transparent texture for the light because I can still see a little bit of black when the textures are blended together.
  • 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!