My player's sprite wont draw

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

34 Replies - 3801 Views - Last Post: 02 November 2010 - 11:56 PM

#16 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 04:24 PM

Yep, that's the same Ship.cs I have in my old project, Shadow. It's definitely that #else being on the wrong line.
Was This Post Helpful? 1
  • +
  • -

#17 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 04:27 PM

View PostKilorn, on 21 September 2010 - 03:24 PM, said:

Yep, that's the same Ship.cs I have in my old project, Shadow. It's definitely that #else being on the wrong line.


What's wrong with it? It's on the correct line plus he doesn't have any of the Xbox 360 only stuff in his project.

Also I was using this to compare line by line what he had in both ship.cs and game1.cs and there was nothing out of place, not even a single missing ;.

This post has been edited by ShadowsEdge19: 21 September 2010 - 04:29 PM

Was This Post Helpful? 1
  • +
  • -

#18 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 04:31 PM

Line 52 of the latest Ship class that he pasted.
Was This Post Helpful? 1
  • +
  • -

#19 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 04:33 PM

Ah I see it now, miss an hour's worth of posts and I miss the eureka moment.
Was This Post Helpful? 1
  • +
  • -

#20 Dev1462  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 20-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 05:01 PM

Ok one problem down. The sprite does indeed draw. Now the main issue is, is that the sprite will not move. my code hasnt been altered except for the new line for the #else, anyone have an idea?

edit:
haha all you chaps get rep, rep all around!
i noticed the book adds keyboard = Keyboard.GetState(); to the Game1 update method, but thats impossible because he calls it in the Ship.cs and everytime i put it there i get a syntax error telling me keyboard doesnt exist...

This post has been edited by Dev1462: 21 September 2010 - 05:08 PM

Was This Post Helpful? 0
  • +
  • -

#21 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 05:16 PM

Glad you got that worked out! Any other issues right now?
Was This Post Helpful? 0
  • +
  • -

#22 Dev1462  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 20-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 05:18 PM

yeah what i just posted above haha.
Was This Post Helpful? 0
  • +
  • -

#23 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 05:29 PM

Well, if you do not declare the variable keyboard, then it'll tell you that keyboard doesn't exist. Try declaring it at the top of your Game1 class KeyboardState keyboard = Keyboard.GetState();
Was This Post Helpful? 0
  • +
  • -

#24 Dev1462  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 20-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 05:36 PM

View PostKilorn, on 21 September 2010 - 04:29 PM, said:

Well, if you do not declare the variable keyboard, then it'll tell you that keyboard doesn't exist. Try declaring it at the top of your Game1 class KeyboardState keyboard = Keyboard.GetState();


yeah i just tried that, and i got it to fit in, but i still cant move my character around. My character controls are in the update method for the Ship.cs class. Now im just stuck with that. probably some other stupid little thing
Was This Post Helpful? 0
  • +
  • -

#25 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 06:11 PM

View PostDev1462, on 21 September 2010 - 04:36 PM, said:

View PostKilorn, on 21 September 2010 - 04:29 PM, said:

Well, if you do not declare the variable keyboard, then it'll tell you that keyboard doesn't exist. Try declaring it at the top of your Game1 class KeyboardState keyboard = Keyboard.GetState();


yeah i just tried that, and i got it to fit in, but i still cant move my character around. My character controls are in the update method for the Ship.cs class. Now im just stuck with that. probably some other stupid little thing


You put KeyboardState keyboard in the declarations of game1 but you have to initialize keyboard = Keyboard.GetState() in game1's Update otherwise it'll find the one state when the game starts (which will be do nothing) and it won't get updated at all.

This post has been edited by ShadowsEdge19: 21 September 2010 - 06:17 PM

Was This Post Helpful? 0
  • +
  • -

#26 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 06:22 PM

I have it declared and initialized at the top of the Game1 class as well as initialized in the Update method... I just noticed that, and I have no idea why it's done that way. haha I enjoy looking at the code I wrote so long ago and laughing at the little mistakes that I made back then.

EDIT: Just tested my code and it doesn't matter where it's initialized, it will still work the way it's supposed to.

And also, even if I take the declaration and initialization out of the game1 class all together, it also still works... I'll dig around some more in your code and hopefully find a solution for you in a minute.

NEW EDIT: On line 73 of your Ship.cs class, at least the one that's posted on page 1 that you posted for me, you have KeyboardState keyboard = new KeyboardState(); this should be changed to KeyboardState keyboard = Keyboard.GetState();.

This post has been edited by Kilorn: 21 September 2010 - 06:33 PM

Was This Post Helpful? 0
  • +
  • -

#27 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 06:29 PM

View PostKilorn, on 21 September 2010 - 05:22 PM, said:

I have it declared and initialized at the top of the Game1 class as well as initialized in the Update method... I just noticed that, and I have no idea why it's done that way. haha I enjoy looking at the code I wrote so long ago and laughing at the little mistakes that I made back then.

EDIT: Just tested my code and it doesn't matter where it's initialized, it will still work the way it's supposed to.

And also, even if I take the declaration and initialization out of the game1 class all together, it also still works... I'll dig around some more in your code and hopefully find a solution for you in a minute.


If only I had problems as small as this in my project
Was This Post Helpful? 0
  • +
  • -

#28 Dev1462  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 20-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 06:32 PM

Haha i see some of us are having fun here :P Anyway here is my declaration in the Game1 class

KeyboardState keyboard;



And here it is being initialized in the Update method of Game1. I dont understand why it isnt working

protected override void Update(GameTime gameTime)
        {
            keyboard = Keyboard.GetState();
            if (player == null)
                Start();
            base.Update(gameTime);
        }


Was This Post Helpful? 0
  • +
  • -

#29 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 06:35 PM

I just edited my last post with what I believe is the solution. Let me know if it works for ya.

View PostShadowsEdge19, on 21 September 2010 - 08:29 PM, said:

View PostKilorn, on 21 September 2010 - 05:22 PM, said:

I have it declared and initialized at the top of the Game1 class as well as initialized in the Update method... I just noticed that, and I have no idea why it's done that way. haha I enjoy looking at the code I wrote so long ago and laughing at the little mistakes that I made back then.

EDIT: Just tested my code and it doesn't matter where it's initialized, it will still work the way it's supposed to.

And also, even if I take the declaration and initialization out of the game1 class all together, it also still works... I'll dig around some more in your code and hopefully find a solution for you in a minute.


If only I had problems as small as this in my project



I don't want to derail the discussion, but are you still having issues with the logic in your game not allowing the player to actually do anything after cycling through all the AI's?
Was This Post Helpful? 1
  • +
  • -

#30 Dev1462  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 20-May 10

Re: My player's sprite wont draw

Posted 21 September 2010 - 06:41 PM

yeah i saw the post. and yes, it doesnt matter if i initialize it in the class or in the update method or not at all. So then yeah there must be something wrong with the game logic. But i dont know what and im so stuck on this

edit: ok re-read it, quoting it didnt show the new edit. anyway, in the Ship.cs if i change it from KeyboardState keyboard = new KeyboardState(); to Keyboard.GetState(); i get a syntax error telling me that it is a method but im using it like a state.

This post has been edited by Dev1462: 21 September 2010 - 06:46 PM

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3