Jump to content

  • Log In with Google      Sign In   
  • Create Account

GameGeezer

Member Since 07 Feb 2010
Offline Last Active Oct 23 2014 12:49 PM

Posts I've Made

In Topic: Slow performance on A*

15 October 2014 - 10:41 AM

Nesting loops will cause an exponential loss in performance and your algorithm is nested three loops deep.

 

Your worst case scenario is: 100(tries) * weightsgrid.size * getadjacent(coords) = ? some number that is probably pretty big

 

NO NESTED LOOPS! (unless they’re actually needed)


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;
    }



PARTNERS