Jump to content
  • Advertisement

Whiskydog

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

235 Neutral

About Whiskydog

  • Rank
    Newbie

Personal Information

  • Interests
    |programmer|
  1.   I'm already using styles.   For the style's drawable you (usually) want a Ninepatch (since the width's dependant of the text u'll put in the button) and having a ninepatch with a background on it will look bad when stretched since that's the point of the ninepatch. If I don't use a ninepatch however I'd have fixed size buttons? What if the text I'll put in the button is larger (wider) than the button itself? That's the problem I'm trying to solve: have 'dynamic' buttons (as in sizable to whatever u want) but with a background (without having it stretched).   In any case, thanks for replying!  :)
  2. Hi, so I'm making an UI and I can't figure out how to have a (Text) Button with a background independent of the stretching that the button itself may apply. I tried adding the image to it (since Button extends Table) but didn't work. I'm aware I could just put the background as the ninepatch but it gets horribly stretched since... well... it'd be a ninepatch. The button's Table.setBackground() method doesn't work either...   I also thought of using an ImageButton but apparently that's not what it'd be used for (from Scene2D.ui's wiki):     I'm really at a loss on how to solve this particular problem, help will be appreciated  :)
  3. Whiskydog

    Lwjgl novice

    libGDX user here, I just wanna add that this kind of frameworks are cool for when u don't want the overhead and... let's say 'hand-holdiness'... of an engine, but u still don't wanna get too much onto the low level side of things. It's great if u want to learn programming and not "just making a game".
  4. Whiskydog

    Managing game logic?

    You could skip the use of an 'EntityManager' and manage them entities updates in the main Game class, I don't really see anything super bad in that. For collisions you could have a Controller that u use as a component in every entity (like the 2DController Sebastian Lague makes on his Unity platformer tutorial for example); or just manage the collisions in each entity 'customly'. For example I have my Projectile class with it's own CheckEnemyCollisions method that gets called in every enemy in the room (I wouldn't do it like that on a, for example, sandbox; it may be neccesary the use of quadtrees in there for optimization purposes, you don't wanna check collisions on a enemy you KNOW it's like 1 km away lul), and if it detects a collision it even takes health away from the enemy who it collided with.   I don't think having this behaviour would be considered spaghetti code, it may be breaking encapsulation a bit but I prefer to have 1 line of damage code in my projectile and run it when it collides with an enemy than having a whole class wih events and such just for it. And say that I want enemies to shoot to, I could abstract all the projectile's movement and other general functionality in a superior Projectile class and have my now PlayerProjectile class a subclass of it, and only implement the CheckEnemyCollisions for THAT kind of projectile alone, and even have a method in my Enemy class called takeDamage (calling it in the aforementioned method) so I don't mess with variables that should be private of the Enemy class in my Player class directly.   I wanna point out that u should take my advice with a grain of salt tho, since I'm no authority, but just a fellow beginner who has had the same headache u are goin thro (not knowing how to structure my game) and that finally decided on use the approach I'm talking about, which so far haven't given me any real pain; and also that I'm basing advice in my current situation only, just because it's the only basis I have for giving any advice at all :D
  5. Whiskydog

    Managing game logic?

    I'm making a Zelda/Isaac dungeon crawler using libGDX, and my way of handling it was having entities with their own update() method and call all of them in my main Game class's own update method. The same for rendering, I have each entity having their own render method that gets called in the Game's. I believe that's the most common approach too, having an Entity-Component System each one managing itself.
  6. Whiskydog

    What rendering tool to use

    Yeah I started making games in Java after reading +500 pages of Head First Java (and ~1.5 year of previous learning on C and messing with Unity), and soon realized that Swing is not meant for games too much. Now I'm using libGdx, made a Blackjack game with dealer and split and stuff, then a local-multiplayer TicTacToe. Now I'm trying to make an Isaac-ish 'thing' but I'm kinda stuck.   But yeah my point is that libGdx definetly has some power in it! And when it comes to learning libGdx itself is not that big of a deal at least for me. Besides the documentation, tutorials and Questions&Answers about it are pretty solid and abundant like Avalander says.   I found myself stuck more in how to structure my game (where to handle Animations and Input, "what should go really in the Player class?", "is an enemy entity collection the way to go?") than learning libGdx 'shenanigans'.
  7. Wow thanks for the answers guys, I appreciate it :D   So yeah gotcha, not use enums as classes basically. That nailed particularly with the explanation on how C# treats enums too.       I think I understand this, but I'm not deciding what to render on my enum, but on a BoardRenderer class' method: public void render() { // BoardRenderer's render method called in main Game class render() after an input update and stuff shapeRend.begin(ShapeType.Line); renderBoard(); // Here I render the board outlines... for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { if(game.playBoard[i][j].seed == Seed.CROSS) // This right here, being 'game' a reference to my Game class where I make the array matrix renderX(game.playBoard[i][j].position); // I pass the cell position else if(game.playBoard[i][j].seed == Seed.CIRCLE) renderO(game.playBoard[i][j].position); // I pass the cell position } } shapeRend.end(); } You mean having this loop on my game class and calling BoardRenderer.renderX / renderO directly from there after looping through my seeds? I mean I would still need to use conditionals and wouldn't I be breaking the Renderer class 'encapsulation'?   Sorry if I don't get it right away, I'm fairly new to actual programming after having somewhat learned the basics of Java :P
  8.   Well see all the methods in those examples are returns and the variables final and stuff. It even says it: "special data type that enables for a variable to be a set of predefined constants", so yeah, no point in wanting it to have instance variables ahaha. Btw I found another answer here now: http://stackoverflow.com/questions/26326291/how-does-java-support-instance-variables-of-java-enum-constants Of course AFTER making this post  -_-  -_-     But anyway I'll take this chance for some more shameless reasurring; in this rendering loop: for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { switch(game.playBoard[i][j].seed) { case CROSS: renderX(game.playBoard[i][j].position); break; case CIRCLE: renderO(game.playBoard[i][j].position); break; default: break; } } } Should I'll be using switch on a per-step method ( since this will be called on libGDX's render() ), or a simple if else would be (far) more efficient?
  9. Hi, so I'm making a Tictactoe game (on libGDX) and thought of having Enums for the grid's 'mark state', and also thought "why not store the grid's position on that enum too?" Thinking about it now doing that's kinda silly I know; but it seems I discovered something about enums I didn't knew, and googling about I couldn't find anything on it reassuring my discovery, so I come here :)   So first I made this Enum: public enum Seed { EMPTY, CROSS, CIRCLE; Vector2 position; } Then went ahead and implemented the initialization code and loop (deleted unrelevant code): public class Game extends ApplicationAdapter { Seed[][] playBoard; @Override public void create () { playBoard = new Seed[3][3]; buildPlayBoard(); } public void buildPlayBoard() { for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { playBoard[i][j] = Seed.EMPTY; playBoard[i][j].position = new Vector2(); switch(i) { case 0: playBoard[i][j].position.x = BoardRenderer.firstColumn; break; case 1: playBoard[i][j].position.x = BoardRenderer.secondColumn; break; case 2: playBoard[i][j].position.x = BoardRenderer.thirdColumn; break; } switch(j) { case 0: playBoard[i][j].position.y = BoardRenderer.firstRow; break; case 1: playBoard[i][j].position.y = BoardRenderer.secondRow; break; case 2: playBoard[i][j].position.y = BoardRenderer.thirdRow; break; } } } } } But I found that all my enum's(grid) position vectors would end up being (thirdColumn, thirdRow) no matter what... Debugging I first thought making new Vector2 was resseting my vectors, but obviously that wasn't the case, nor the switch statements. That's when I found out the 'position' vector on the Seed class was being treated as static or something, storing all positions as the last iteration [2][2]...   I then verified this by making a Panel class with their own Seed and 'position' variable... public class Panel { Vector2 position; Seed seed; public Panel() { seed = Seed.EMPTY; position = new Vector2(); } } Founding that this way my initialization method would work as intended with the SAME algorithm (with playBoard being a Panel[3][3]): public void buildPlayBoard() { for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { playBoard[i][j] = new Panel(); switch(i) { case 0: playBoard[i][j].position.x = BoardRenderer.firstColumn; break; case 1: playBoard[i][j].position.x = BoardRenderer.secondColumn; break; case 2: playBoard[i][j].position.x = BoardRenderer.thirdColumn; break; } switch(j) { case 0: playBoard[i][j].position.y = BoardRenderer.firstRow; break; case 1: playBoard[i][j].position.y = BoardRenderer.secondRow; break; case 2: playBoard[i][j].position.y = BoardRenderer.thirdRow; break; } } } } And with the Seed enum being just... an enum :P public enum Seed { EMPTY, CROSS, CIRCLE; } So am I being st**id or do Enums actually behave static-ish with their variables?
  • 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!