Jump to content

  • Log In with Google      Sign In   
  • Create Account


GameGeazer

Member Since 07 Feb 2010
Offline Last Active Jul 18 2014 04:18 PM
-----

Posts I've Made

In Topic: Help with matrix rotation

15 May 2014 - 10:36 PM

So when I'm rotating I can simply multiply the old_rotation by the new_rotation? The only difference between world and local being I translate local back to the origin before rotating?

 

I'm a bit confused as to how you tell the difference between a world and local rotation if the translation is in a separate matrix. As  of now I'm storing my world and local rotation separately and multiplying world * translation* local, which seems to work fine but do you know how it's usually done?

 

4. That's an interesting idea, as of now the child is not in respect to the parent but your method looks very elegant.

 

Thank you very much that helped a lot.


In Topic: Dynamic Slime Blob Generation

03 May 2014 - 06:18 PM

I could be leading you astray but could you have a multitextured surface where the geometry covered by the "infected" texture is subdivided in the geometry shader than displayed in the vertex shader?


In Topic: Need feedback on code design for maps of an RPG

13 February 2014 - 06:02 PM

 


Try not to create objects when it's not necessary. Why not just check if the player's x, y coordinates are within the camera frustum, if not shift the Scene.
 

 

I need the rectangles which are the bounding box for the walls in the map. Without those, I cannot do collision. 

 

Try translating the boxes instead of creating new objects.


In Topic: Need feedback on code design for maps of an RPG

13 February 2014 - 01:03 PM

public int getX()
{
return super.getX();
}

This is neither necessary nor proper style. The geX() method inherited will be visible as long as it's public.

int rectWidth = 50;
             int rectHeight = 50;
             // left
             leftRectangle = new Rectangle(((int)(getWidth() * -.04)) - camera.getX(),getY() - camera.getY(),rectWidth,getHeight());
             // right
             rightRectangle = new Rectangle(((int)(getWidth())) - camera.getX(),getY() - camera.getY(),rectWidth,getHeight());
             // top
             topRectangle = new Rectangle((int)(getWidth() *  0)- camera.getX(),(int) ((getHeight() * -0.06) - camera.getY()) ,getWidth(),rectHeight);
             // down
             downRectangle = new Rectangle((int)(getWidth() * 0)- camera.getX(),getHeight()  - camera.getY() ,getWidth(),rectHeight);
 
 
 
             if(link.getRectangle().intersects(leftRectangle))
             {
                       MapTracker.SCREEN = 1;
             }
             // right wall collision
             else if(link.getX() + link.getIdleRightWidth() > ((int)(getWidth())) - camera.getX())
             {
                       camera.setX(camera.getX() - camera.getSpeed());
             }
             // top wall collision
             else if(link.getY() < (int) ((getHeight() * -0.06) - camera.getY()) + topRectangle.getHeight() - 10 )
             { 
                       camera.setY(camera.getY() + camera.getSpeed());
             }
             // down wall collision
             else if( (link.getY() + link.getIdleDownHeight() > downRectangle.getY()))
             { 
                       camera.setY(camera.getY() - camera.getSpeed());
             }

Try not to create objects when it's not necessary. Why not just check if the player's x, y coordinates are within the camera frustum, if not shift the Scene.

 

Try using a node based scene heiarchy it will be much more flexible

/**
 *
 * @author William Gervasio
 *
 */

import java.util.ArrayList;
import java.util.List;

import core.util.Node;
import core.util.math.Vector2;


public abstract class SceneNode extends Node<SceneNode> {

    private Vector2 translation;
    private List<IBehavior> behaviors = new ArrayList<IBehavior>();
    private float sceneTime;

    public SceneNode() {
        this(new Vector2());
    }

    public SceneNode(Vector2 translation) {
        this.translation = translation;
    }

    public void render(int delta) {
        for (Node<SceneNode> node : this.getSubnodes()) {
            ((SceneNode) node).render(delta);
        }
    }

    public void renderDebug(int delta) {
        for (Node<SceneNode> node : this.getSubnodes()) {
            ((SceneNode) node).renderDebug(delta);
        }
    }

    public void update(int delta) {
        this.sceneTime += delta;

        for (IBehavior behavior : behaviors) {
            behavior.act(this);
        }

        for (Node<SceneNode> node : this.getSubnodes()) {
            ((SceneNode) node).update(delta);
        }
    }

    public SceneNode setTranslation(Vector2 translation) {
        return setTranslation(translation.x, translation.y);
    }

    public SceneNode setTranslation(float x, float y) {
        for (Node<SceneNode> node : this.getSubnodes()) {
            Vector2 offset = ((SceneNode) node).getTranslation().sub(x, y);
            ((SceneNode) node).setTranslation(offset.add(x, y));
        }
        translation.set(x, y);

        return this;
    }

    public SceneNode translate(Vector2 translation) {
        return translate(translation.x, translation.y);
    }

    public SceneNode translate(float x, float y) {
        for (Node<SceneNode> node : this.getSubnodes()) {
            ((SceneNode) node).getTranslation().add(x, y);
        }
        translation.add(x, y);

        return this;
    }

    public Vector2 getTranslation() {
        return translation;
    }

    public float getX() {
        return translation.x;
    }

    public float getY() {
        return translation.y;
    }

    public float getSceneTime() {
        return sceneTime;
    }

/**
 *
 * @author William Gervasio
 *
 */

import java.util.ArrayList;
import java.util.List;

public class Node<T> implements Cloneable {

    private List<Node<T>> subnodes;

    public Node() {
        this(new ArrayList<Node<T>>());
    }

    public Node(List<Node<T>> subnodes) {
        this.subnodes = subnodes;
    }

    public void attach(Node<T> node) {
        subnodes.add(node);
    }

    public void clearNodes() {
        subnodes.clear();
    }

    public void detach(Node<T> node) {
        subnodes.remove(node);
    }

    public void deepDetach(T node) {
        subnodes.remove(node);
        for (Node<T> i : subnodes) {
            i.deepDetach(node);
        }
    }

    public boolean hasNode(Node<T> node) {
        return subnodes.contains(node);
    }

    public List<Node<T>> getSubnodes() {
        return subnodes;
    }

    public void setSubnodes(List<Node<T>> subnodes) {
        this.subnodes = subnodes;
    }



In Topic: Entity Manager->Game Logic

10 December 2013 - 08:02 PM

I try to only create objects for "tangible" ideas. A MouseManager manages the mouse, a Application executes a game, ect. All logic for your Game object should go in your Game class, but if you feel it's becomming bloated or messy try and think of a way to abstract it. Maybe take a look at an opensource library like libgdx and see How they're managing entities. Try not to create more objects then you need, having a "logic" class for game logic seems a bit out of place.

 

You really shouldn't worry about code design as much as you might think. Next game you'll salvage as many mangled pieces of this game as you can and probably rewrite most of your code base with new found experience.

 

I've taken up using Unity because I cannot stop myslef over engineer my frameworks. Maybe look at an engine if games are your focus. There is shame yes but it's nice to actually make progress.


PARTNERS