O'Reilly Forums: Saving The Humans - Animateenemy() Problem - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Saving The Humans - Animateenemy() Problem

#1 User is offline   Ultigma 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 11-March 14

Posted 11 March 2014 - 10:53 AM

Problem Solved
Turns out it was my playArea's width and height was 0 so no play area actually exsisted...
SILLY ME!

How I figured it out was to check the stack trace. I did this by looking t at he "Locals" tab in the bottom window, and opening each property that had "+base" till there was no more and clicked the magnifying glass on the error and viewed the stack trace.

Perhaps this might help someone else figure out their problem?

Cheers
------------------------------------------------------------------------------------------------

Hello, literally just signed up hoping to find an answer =)

I have been following the code as stated and have hit a problem I'm not to sure about. I tried to work it out but with my limited knowledge, not sure what I'm doing.

When I click the start Button I hit an error:

" An exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll but was not handled in user code

Additional information: 'maxValue' must be greater than zero. ".

and it highlights this part of the code.

AnimateEnemy(enemy, [b]random.Next((int)playArea.ActualHeight - 100),
                random.Next((int)playArea.ActualHeight - 100)[/b], "(Canvas.Top)");


Not sure what this is referring to, pretty sure everything is as typed in the book.

Thanks for any help
Update!

After scanning the code, I found out it was something to do with the random.Next((int)playArea.ActualHeight - 100),
random.Next((int)playArea.ActualHeight - 100)


Is there something wrong with the way it is formatted? According to the IDE it's returning 0.

This post has been edited by Ultigma: 11 March 2014 - 12:36 PM

0

#2 User is offline   wunderwaffe 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 26
  • Joined: 14-January 14

Posted 12 March 2014 - 01:52 AM

View PostUltigma, on 11 March 2014 - 10:53 AM, said:

Problem Solved
Turns out it was my playArea's width and height was 0 so no play area actually exsisted...
SILLY ME!

How I figured it out was to check the stack trace. I did this by looking t at he "Locals" tab in the bottom window, and opening each property that had "+base" till there was no more and clicked the magnifying glass on the error and viewed the stack trace.

Perhaps this might help someone else figure out their problem?

Cheers
------------------------------------------------------------------------------------------------

Hello, literally just signed up hoping to find an answer =)

I have been following the code as stated and have hit a problem I'm not to sure about. I tried to work it out but with my limited knowledge, not sure what I'm doing.

When I click the start Button I hit an error:

" An exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll but was not handled in user code

Additional information: 'maxValue' must be greater than zero. ".

and it highlights this part of the code.

AnimateEnemy(enemy, [b]random.Next((int)playArea.ActualHeight - 100),
                random.Next((int)playArea.ActualHeight - 100)[/b], "(Canvas.Top)");


Not sure what this is referring to, pretty sure everything is as typed in the book.

Thanks for any help
Update!

After scanning the code, I found out it was something to do with the random.Next((int)playArea.ActualHeight - 100),
random.Next((int)playArea.ActualHeight - 100)


Is there something wrong with the way it is formatted? According to the IDE it's returning 0.


Indeed, I'm average at coding but I'm pretty competent at debugging.

One of the things Andrew deserves credit for (at least in the 2nd ed.) is introducing Debugging in Chapter 2.

Sharing ideas that help people help themselves is always good.

:)
0

#3 User is offline   AndrewStellman 

  • Andrew Stellman
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 757
  • Joined: 08-October 08
  • Gender:Male
  • Location:Brooklyn, NY
  • Interests:Author of: "Head First C#", "Beautiful Teams", "Head First PMP", "Applied Software Project Management"

Posted 12 March 2014 - 11:47 AM

Thanks! That was an improvement I made with the second edition -- the first edition pushed it back to later in the book, and it was one of the first things I corrected the second time around.
Andrew Stellman
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users