Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

127 Neutral

About Mannas

  • Rank
  1. Back home!     When i first read "3x3 homogenous matrix" i had no clue of what were talking about. It has been a while since my last math class. So i did some research and now i think i understand what you mean. But i'm not sure how to implement all that.   How i understand it (i'm not saying this is the way it is, this is just what i made of it from the info i read and the info you gave): In the different objects get an extra parameter Transformation: private transformation AffineTransform; This transformation is set to the world: [ 1 0 0 ] [ 0 1 0 ] [ 0 0 1 ] If i understood correctly: if you put your objects' coordinates x and y through this matrix, they come back the same. So your coordinates are just what they are in the world.   But now if you want your object to follow a parent, you concat the transformation (AffineTransform) of your object with the coordinates of your parent.   As i'm writing this i get more and more confused. :s For instance: Should the coordinates x and y and a (rotation) not all be replaced by a matrix by itself. But then an object has two transformation => one for it's coordinates and one for it's actual placement in the world/parent...     Again, how i understand it:  So you have an extra "coupling" object that has two parameters => the parent parameter and the child parameter. And you continuously concat the transformation of your child with the coordinates of your parent.  Here again i think i don't really understand it all the way, because it would make more sense if the coordinates of the parent would be in a transformation matrix. In that way you can just set the transformation with the coordinate-transformation of the parent and your done. If the latter is correct, do you only have to call this extra object once  at initialization? Or even further: is this object really necessary? Can't i just set the parents transformation at the child's construction?     I'm sorry if my response is rubbish, i'm just kinda confused about it atm!
  2. Sorry for my late respons (being on holidays prevents me from constant phone access to write an answer :-P) I think I understand what you mean, but I don't really see how to implement it. Like I understand it: The machine is the parent and the zone is the child. So the machine does the rendering of the zone (for example sake the zone is a visible component). But as you said earlier, an object doesn't do it's own rendering, so does the machine add it's sprite together with the zones' sprite and give it to the renderer as a 'spriteset' or so? As we are talking about doing the rendering outside the object, how does this work? Does the renderer iterate over all the objects, take their sprites and draw them on the coordinates+rotation of the object?
  3. Thanks again for your quick response. You're great! I would have two variables in my machine class: Public Zone pickZone; Public Zone dropZone; Which are references to the zone objects. They are initialized when a machine is created. Let's say the selling of a machine is done outside the machine class, how would you find out which zones to destroy together with the machine if you don't have these two variables? I really like the idea of keeping everything as separate as possible, but atm I don't see how to know what belongs to what, how do you cross-reference everything together? I'm not familiar with this. I've been trying to Google it, but for now only results about divorcing parents :-) I keep looking! (If anyone has good sources about that you may always let me know) . I'm sorry if all this is obvious or basic stuff that I should know, I'm just learning atm. I try to soak up as much as I can :-)
  4. Gratitude for your quick response! I see your point about not doing the collisions in the player. I think I'll change it that way. It also didn't occur to me before to see the drop-off/pick-up area's as separate objects. It seems like a good idea! One thing though: should the machine and the area-objects not stay connected? For instance let's say one of the machines is mobile and it moved around. The areas have to move along, or the player sells a machine, the areas have to be destroyed. It seems like if I write all that outside the machine class it's gonna get messy! About the products: Is it better to let them only exist in the player/machine, or should I also put them in a collection of some kind. I'm not sure what is best. I'm leaning more to the first option, because it is less overhead and simpler, but then what to do when the player drops it's product, it should still exist on it's own. Thanks again for your answer! It has already been great advice. When I get home, I'll implement the changes and check things out right away!
  5. I'm making a game using libgdx. I'm kinda new to making games but I have experience in programming (production machines mainly). In my game my player walks around in a 2d world with wall objects and machine objects (that's all for now, I'm taking things step by step). The object is for the player to move products from one machine to the other. All the wall objects, machine objects and player are all in one linked list. Each object has a render and an update method. So in my gameloop I can loop through all my objects and update and render them. Now I'm kinda stuck with what to do with the products! The player has a private product and the machine has a private linked list of products. When the player notices he enters the drop-off area of a machine, the product has to go from the player to the machine, and vise versa when the player enters pick-up zone. An extra problem:A machine can refuse a product when it's full, or when the product not the right type for the machine. Detecting the player is in the zones is no problem. It's the transfer that bugs me. I want to do the transfer in the player class. Because the player noticed it was in one of the zones of a machine. How I do the transfer from player to machine now: If my player detects it's in a machinesobjects drop-off zone it calls the add method of the machine object: succeeded=machineobject.AddProduct(playerProduct); If (succeeded) playerProduct = null; If the machine accepts the product, and it can be deleted from the players product. This works, but it doesn't seem like the best practice... How I do the transfer from machine to player now: If my player detects it's in a machinesobjects pick-up zone it calls the get method of the machine object: playerProduct=machineobject.GetProduct(); This look kinda ok. But the machine object method does look kinda messy: (for example sake I used one object instead of the linked list the machine normally has) Public Product GetProduct() { If (product!= null) { Product tempProduct = product; product = Null; Return tempProduct; } Else{ Return Null; } } Again if I recall correctly, this works, but it doesn't seem like the best practice... So my actual question: what is a good way to transfer objects from one class to another, and I what is the best way to manage these transferable objects in a game (eg put them in a separate list, put them in the list with all the other objects...) I'm sorry if my text looks kinda messy or my fonts aren't all correct, but I'm on a vacation with my gf and all I have to my disposal is my cell phone :-) This just kept bugging me so I couldn't wait till I got home :-) Thanks in advance for any replies!
  • 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!