• 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
SnakeBr

Error only in Release Mode

6 posts in this topic

Since I´m a novice programmer does not understand why this error happens, I have a class that represents a port, the attributes of the class are

[code]
class Door : GameObjects
{
private Matrix[] DoorMatrix;

public bool dIsActive { get; set; }
public float time { get; set; }

private string DoorDirection;

private ModelBone DoorBone;
private ModelBone HandleDoorBone;

private Matrix mDoorTransform;
private Matrix mDoorHandleTransform;

private Vector3 PivotOfDoor;
private Vector3 PivotDoorHandle;

float Rotation;
float hRotation;
float angle;

float temp1 = 0f;
float temp2 = 0f;

//to doors
Matrix mDoorRotation;
Matrix PivotToOrigin;
Matrix OriginToPivot;
Matrix DoorRotationAboutPivot;

//to handle door

Matrix PivotToOriginHandle;
Matrix mDoorHandleRotation;
Matrix OriginToPivotHandle;
Matrix DoorHandleRotationAboutPivot;
}[/code]


In the Load method of the class called in the class constructor:
[code]
mDoorRotation = Matrix.Identity;
PivotToOrigin = Matrix.Identity;
OriginToPivot = Matrix.Identity;
DoorRotationAboutPivot = Matrix.Identity;

PivotToOriginHandle = Matrix.Identity;
mDoorHandleRotation = Matrix.Identity;
OriginToPivotHandle = Matrix.Identity;
DoorHandleRotationAboutPivot = Matrix.Identity;


ModelName = Content.Load<Model>(NameModel);
DoorMatrix = new Matrix[ModelName.Bones.Count];
DoorBone = ModelName.Bones[Bone01];
HandleDoorBone = ModelName.Bones[Bone02];
mDoorTransform = DoorBone.Transform;
mDoorHandleTransform = HandleDoorBone.Transform;
DoorDirection = "R";
PivotOfDoor = new Vector3(-13.065f, -1.208f, 1.119f)
PivotDoorHandle = Vector3.Zero;
Rotation = 120f;
hRotation = 50f;
angle = 120f[/code]


In the Update method of the class Door:

[code]
public void Update()
{
MoveHandleDoor();
OpenDoor();
}[/code]



The method MoveHandleDoor:
[code]
private void MoveHandleDoor()
{
if (dIsActive)
{
PivotToOriginHandle = Matrix.CreateScale(ModelScale) *
Matrix.CreateTranslation(-PivotDoorHandle);


this.mDoorHandleRotation = Matrix.CreateRotationZ(
MathHelper.Clamp(hRotation -= 0.1f * time,
MathHelper.ToRadians(-50f), MathHelper.ToRadians(0f)));


this.OriginToPivotHandle = Matrix.CreateScale(ModelScale) *
Matrix.CreateTranslation(PivotDoorHandle);

DoorHandleRotationAboutPivot =
PivotToOriginHandle * mDoorHandleRotation * OriginToPivotHandle;

HandleDoorBone.Transform = DoorHandleRotationAboutPivot * mDoorHandleTransform;
}
}[/code]



The method opendoor:
[code]
private void OpenDoor()
{
if (dIsActive)
{
PivotToOrigin = Matrix.CreateScale(ModelScale) *
Matrix.CreateTranslation(-PivotOfDoor);
if (DoorDirection == "L" || DoorDirection == "l")
{
mDoorRotation = Matrix.CreateRotationZ(
temp1 = MathHelper.Clamp(Rotation -= 0.001f * time,
MathHelper.ToRadians(-angle), MathHelper.ToRadians(0f)));

if( temp1 == MathHelper.ToRadians(-angle))
ReverseHandleDoor();

sounds.PlaySoundDoor("MetalDoor");

}
if (DoorDirection == "R" || DoorDirection == "r")
{
mDoorRotation = Matrix.CreateRotationZ(
temp2 = MathHelper.Clamp(Rotation += 0.001f * time,
MathHelper.ToRadians(0f), MathHelper.ToRadians(angle)));

if (temp2 == MathHelper.ToRadians(angle))
ReverseHandleDoor();

sounds.PlaySoundDoor("MetalDoor");


}
OriginToPivot = Matrix.CreateScale(ModelScale) *
Matrix.CreateTranslation(PivotOfDoor);
DoorRotationAboutPivot = PivotToOrigin * mDoorRotation * OriginToPivot;
DoorBone.Transform = mDoorTransform * DoorRotationAboutPivot;

}
sounds.UpdateSounds();

}[/code]


And the method is ReverseHandleDoor:
[code]
private void ReverseHandleDoor()
{
if (dIsActive)
{
PivotToOriginHandle = Matrix.CreateScale(ModelScale) *
Matrix.CreateTranslation(-PivotDoorHandle);


this.mDoorHandleRotation = Matrix.CreateRotationZ(
MathHelper.Clamp(hRotation += 0.1f * time ,
MathHelper.ToRadians(0f), MathHelper.ToRadians(50f)));


this.OriginToPivotHandle = Matrix.CreateScale(ModelScale) *
Matrix.CreateTranslation(PivotDoorHandle);

DoorHandleRotationAboutPivot =
PivotToOriginHandle * mDoorHandleRotation * OriginToPivotHandle;

HandleDoorBone.Transform = DoorHandleRotationAboutPivot * mDoorHandleTransform;
}
}[/code]




In the Update method is in Game1.cs
[code]
/ / The correct speed for the sound to be synchronized with the
/ / Motion model
door01.time = (float) gameTime.ElapsedGameTime.TotalMilliseconds / 2f;

/ / Triggers the movement of the door model
/ / This is just a test

if (Keyboard.GetState (). IsKeyDown (Keys.V))
door00.dIsActive = true;
door00.Update ();[/code]


Everything works fine in Debug mode, but in Release Mode the method ReverseHandleDoor is not called, then the door knob only turns to one side but does not return the right direction.

Could anyone tell me why this happens? The method works in Debug mode and crash in Release mode?

Thanks.
0

Share this post


Link to post
Share on other sites
[quote name='SnakeBr' timestamp='1299284955' post='4781942']
Since I´m a novice programmer does not understand why this error happens, I have a class that represents a port, the attributes of the class are

[code]
...
[/code]


Everything works fine in Debug mode, but in Release Mode the method ReverseHandleDoor is not called, then the door knob only turns to one side but does not return the right direction.

Could anyone tell me why this happens? The method works in Debug mode and crash in Release mode?

Thanks.
[/quote]

Does the program "crash" or just not function the way it is intended? In the debug build, your IDE will fill in default values(0) for everything, where as in release it's all up to you. Most likely you are using something that you haven't initialized yourself, and because of that, it will be filled with garbage.
0

Share this post


Link to post
Share on other sites
The program does not crash. What happens is that in debug mode it behaves as expected, as is the video (please see full screen, the program I'm using always makes the image darker and no good I set the lights otherwise):

[media]http://www.youtube.com/watch?v=BhiIRaPR4ZQ[/media]

But when the Release mode is selected, the door handle does not return to normal position. Watch the video:

[media]http://www.youtube.com/watch?v=pEv4FAIkdng[/media]

I've got the project settings and when I deselect the text box "Define DEBUG constant". What I do not understand is that when I deselect the "Define DEBUG constant" (even though we are in Debug mode) which is the same mode setting release the door handle back into position. I do not think that is a problem to pick up garbage from memory, all Matrix used are cleared so that the class is called in the constructor.
0

Share this post


Link to post
Share on other sites
What's almost certainly going wrong here is that you're having floating point precision issues in this bit of code:

[code]if( temp1 == MathHelper.ToRadians(-angle))
ReverseHandleDoor();[/code]

You should never test floats for exact equality. You generally want a test that looks something like: if (abs(b-a) < EPSILON)

For much more detail on how floating point numbers work take a look at http://www.cse.msu.edu/~cse320/Documents/FloatingPoint.pdf
1

Share this post


Link to post
Share on other sites
[quote name='Adam_42' timestamp='1299319593' post='4782028']
What's almost certainly going wrong here is that you're having floating point precision issues in this bit of code:

[code]if( temp1 == MathHelper.ToRadians(-angle))
ReverseHandleDoor();[/code]

You should never test floats for exact equality. You generally want a test that looks something like: if (abs(b-a) < EPSILON)

For much more detail on how floating point numbers work take a look at [url="http://www.cse.msu.edu/%7Ecse320/Documents/FloatingPoint.pdf"]http://www.cse.msu.e...oatingPoint.pdf[/url]
[/quote]

Adam_42 thanks for the help, really you're right. The problem was related to math with float, so now the program in Debug mode when in Release mode is working as expected.
Here's the thing I did differently according to the. pdf you posted.

[code]if (Math.Abs(temp1 - MathHelper.ToRadians(-angle)) < 0.00001f)
ReverseHandleDoor(); [/code]

Thank you also for helping Burnt_Fyr.
0

Share this post


Link to post
Share on other sites
Thanks for the thanks... and here's a tip, rather than using a hard coded value, create a const int or #define macro to hold the value you use for epsilon, just in case you ever need to change it


[code]

const int EPSILON = 0.00001f

//...

if (Math.Abs(temp1 - MathHelper.ToRadians(-angle)) < EPSILON )
ReverseHandleDoor(); [/code]
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