• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
boogyman19946

cannot find symbol even though its defined

2 posts in this topic

Hello folks. It has been a while since I posted on the forums.

 

I've revived a project from ages ago, and I've been going through the source trying to get the thing to work. I'm getting the following errors:

 

E:\NetBeansProjects\Digestion\src\Entity\Entity.java:164: error: cannot find symbol
			mMotionModule.resetTimer();
			             ^
  symbol:   method resetTimer()
  location: variable mMotionModule of type MotionModule
E:\NetBeansProjects\Digestion\src\Entity\Entity.java:173: error: cannot find symbol
			mMotionModule.update(this, manager.getEntities());
			             ^
  symbol:   method update(Entity,LinkedList<Entity>)
  location: variable mMotionModule of type MotionModule
E:\NetBeansProjects\Digestion\src\Entity\Entity.java:176: error: cannot find symbol
			mPathfindingModule.update();
			                  ^
  symbol:   method update()
  location: variable mPathfindingModule of type PathfindingModule
E:\NetBeansProjects\Digestion\src\Entity\Entity.java:189: error: cannot find symbol
			mHealthModule.draw(canvas);
			             ^
  symbol:   method draw(GameCanvas)
  location: variable mHealthModule of type HealthModule
4 errors
E:\NetBeansProjects\Digestion\nbproject\build-impl.xml:605: The following error occurred while executing this line:
E:\NetBeansProjects\Digestion\nbproject\build-impl.xml:246: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

 

I thought this was a rather routine error: I probably just misspelled a few function names. The thing is though, I haven't. To make extra sure, I copied and pasted them into place but the compiler still gives me those errors. Even more strange, NetBeans' error highlighter does not mark these lines as errors. Only the compiler. 

 

Here is the Entity class (errors are marked with line comments)

package Entity;

import java.awt.geom.Rectangle2D;

import Core.Level.Level;
import Core.Messages.Message;
import Core.Messages.MessageQueue;
import Entity.EntityScripting.EntityScript;
import Entity.Modules.*;
import Graphics.GameCanvas;

public class Entity {
	private String mName;
	private Rectangle2D.Float mBoundRect;
	private int mDepth;
	
	private Level mLevel;
	
	private String m_pwd;
	private EntityScript mObjectScript;

	private HealthModule mHealthModule;
	private MotionModule mMotionModule;
	private GraphicsModule mGraphicsModule;
	private SoundModule mSoundModule;
	private PathfindingModule mPathfindingModule;
	
	private MessageQueue mMessageQueue;

	public Entity(Level level) {
		mLevel = level;
		mName = "Default";
		mBoundRect = new Rectangle2D.Float(0, 0, 0, 0);
		m_pwd = null;  
		mObjectScript = null;
		
		mHealthModule = null;
		mMotionModule = null;
		mGraphicsModule = null;
		mPathfindingModule = null;
		mSoundModule = null;
		
		mMessageQueue = new MessageQueue();
	}

	public boolean initialize(String pwd, EntityScript objectScript, int x, int y, String[] arguments) {
		m_pwd = pwd;
		mObjectScript = objectScript;
		
		mBoundRect.x = x;
		mBoundRect.y = y;
		
		mObjectScript.create(this, arguments);
		
		return true;
	}
     
        // ...
        // Snip unrelated functions
        // ...

	public void reset() {
		if(mMotionModule != null)
			mMotionModule.resetTimer();                        // Error occurs here
		
		mObjectScript.reset();
	}
	
	public void update(EntityManager manager) {
		processMessages();
		
		if(mMotionModule != null)
			mMotionModule.update(this, manager.getEntities()); // Error occurs here
		
		if(mPathfindingModule != null)
			mPathfindingModule.update();                       // Error occurs here
		
		mObjectScript.processKeys();
		mObjectScript.update();
	}
	
	public void draw(GameCanvas canvas) {
		if(mGraphicsModule != null) {
			mGraphicsModule.draw(canvas);
			mObjectScript.draw();
		}
		
		if(mHealthModule != null) {
			mHealthModule.draw(canvas);                        // Error occurs here
		}
	}
}

 

 

and the MotionModule class (the error is the same for the other two classes featuring different functions)

 

package Entity.Modules;

import java.awt.geom.*;
import java.util.LinkedList;

import Entity.Entity;
import Util.GameTimer;
import Util.Vector2D;

public class MotionModule {
	private static class Force	{
		String name;
		Vector2D force;
		
		public Force(String name, Vector2D force) {
			this.name = name;
			this.force = force;
		}
	}

	private double mMass;
	
	private Vector2D mVelocity;
	private double mTerminalVelocity;
	
	private LinkedList<Force> mForces;
	
	private Vector2D mJumpForce;
	private boolean mJump;
	private boolean mCanJump;
	private boolean mCanDoubleJump;
	private boolean mDoubleJumpFlag;
	
	private boolean mStopOnSolid;
	private double mGravity;
	
	private GameTimer mTimer;
	
	//////////////////////
	// PUBLIC INTERFACE //
	//////////////////////	
	public MotionModule(double mass, double terminalVelocity) {
		mMass = mass;
		
		mVelocity = new Vector2D(0.0f, 0.0f);
		mTerminalVelocity = terminalVelocity;
		
		mForces = new LinkedList<Force>();
		
		mJumpForce = new Vector2D(0.0, 0.0);
		mJump = false;
		mDoubleJumpFlag = false;
		
		mStopOnSolid = false;
		mGravity = 0.0;
		
		mTimer = new GameTimer();
	}

        // ...
        // Snip unrelated functions
        // ...

	public void resetTimer() {
		mTimer.reset();
	}
	
	public void update(Entity entity, LinkedList<Entity> entityList) {
		// Elapsed time in seconds
		double elapsedTime = getTimeStep();
		
		Rectangle2D.Float entRect = entity.getObjectRect();
		
		//////////////////
		// Move forward //
		//////////////////
		Vector2D deltaPos = integrateVelocity(elapsedTime);
		
		entRect.x += deltaPos.x;
		entRect.y += deltaPos.y;
		
		/////////////////////
		// Check collision //
		/////////////////////
		Entity obstacle = null;
		boolean collisionFree = false;
		while(!collisionFree) {
			for(Entity worldEntity: entityList) {
				if(!entRect.intersects(worldEntity.getObjectRect()))
					continue;

				Rectangle2D.Float obstRect = worldEntity.getObjectRect();

				Vector2D entCenter = new Vector2D(entRect.x + entRect.width/2, entRect.y + entRect.height/2);
				Vector2D obstCenter = new Vector2D(obstRect.x + obstRect.width/2, obstRect.y + obstRect.height/2);

				Vector2D obstClosestCorner = closestCornerToCenter(entCenter, obstRect);
				Vector2D entClosestCorner = closestCornerToCenter(obstCenter, entRect);

				Vector2D posShift = obstClosestCorner.subtract(entClosestCorner).projectOn(deltaPos);

				entClosestCorner = entClosestCorner.subtract(posShift);

				Vector2D collisionNormal = getCollisionNormal(entClosestCorner, obstClosestCorner, deltaPos);
				

				entRect.x -= posShift.x;
				entRect.y -= posShift.y;
			}
			
			collisionFree = true;
		}
	}
}

 

 

The package hierarchy is as follows <src>/Entity/Modules

The Entity class resides in package Entity, whereas all the Modules reside in Entity/Modules

 

Does anyone have any idea as to why I'm getting this seemingly baseless error? Some folks said it has to do with classpaths. I looked through the project properties but I have not found anything that might cause this.

0

Share this post


Link to post
Share on other sites

Everything looks right.  If there is some simple typo or something, then don't feel bad because I don't see it either.  If I had to guess then there is a problem with the packages.  Maybe the folders are all lower case and don't start with a capital letter?  

 

Packages names and folders are all lower case by convention, but I do not know if Java actually cares.  I've never even tried.  If I were you, I would start a new project and create example files with the same packages names and see if that works.

0

Share this post


Link to post
Share on other sites

I had a feeling that it wasn't the code that was generating the error, and it seems I was right. To be extra sure I wasn't going crazy, I compiled the code manually via command line last night and it compiled without problem. To fix the problem, I copied all of the source code, deleted the project in NetBeans, created a new one, and pasted the source back into the right folder. Then NetBeans was able to compiled the source without goofy errors. I intended to post the fix yesterday night but for some reason I was not able to log in, so I'm only able to post the update today.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0