Jump to content
  • Advertisement
Sign in to follow this  
David_Supina

This little piece of code is giving me a headache.

This topic is 3740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm working through what is a rather entertaining and informative C# book, trying to gain some proficiency for tackling an XNA project (so I'm working with Microsoft Visual C# 2005, unlike my book, which uses 2008), and I'm enjoying myself. Sure, I do create occasional bugs, but they're usually easily solved. However, there is one that simply will not go away, no matter how I try to re-write it. The idea of this project is to create a betting simulator. I haven't implemented the betting system yet, and won't until I can show the "race" in action and get data from that to determine the winner. I've put just about everything in place for this version of the program, but there's one line that refuses to work. I'm trying to move along the picture of the dog periodically by a random number of pixels between one and four, but for whatever reason, the second line in the following block of code isn't working: location += Randomizer.Next(1, 5); this.myPictureBox.Location.X = this.location; if (location >= racetrackLength) return true; else return false; This is part of a class that for each instance, I have immediately initialized the "myPictureBox" variable to equal the picture that I am using for the visuals. If my understanding of C# is correct, this should mean that I should be able to use either name interchangeably to make changes to the code. It was giving me problems when I tried to access the myPictureBox variable from the outside, as I have all my objects in an array, and would pick a random number to determine which object would have this method run. What's particularly strange is the error message I'm getting: Error 1 Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable. Of course it isn't a variable. That's why I added the ".X" bit at the end. The odd part is that on the IDE, it only highlights the part of the line up to, and not including, the ".X" bit. Do you know what's happened here? If you need to see more of my code, I'll be happy to provide it.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by DpakoH
well little google search and found this. hope it will help you


y.


Yeah, I think I see what's going on now, but I would have thought that the point variable was simply a special combination of two int variables, and could have its individual X and Y properties modified with an int value accordingly. Ah well. I'll just have to adjust my code a touch to accommodate this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!