🔒 Locked
different way of learning
Advertisement
Original Post
I have 3 xna books and theyre each kicking my ass. I can't seem to get the material thru my brain no matter how many times I go over it. Are there any alternative ways to learning a language? Videos dont work for me either
I know c# well enough to understand the code. I just need longer explanations of why something does what it does
Wouldn't it be easier for you to start writing something and when you get stuck, then post your problem here so others can help you?
yeah but id end up with at least 5 new topics a day and thatd be annoying lol
For you? Or us? Don't forget. You're not the first person with these problems and you're not the last. So asking them and getting your questions answered is gonna help someone else in the long run.
In addition, since others have already had those problems as Alpha_ProgDes mentioned, you'll more likely be googling for the answers about 5 times a day, and find the answer within 15 minutes of googling and not actually need to post. You'll probably only have a question you can't already find the answer to only once a week or so.
It seems unnecessary tho. I learn better when I figure things out by myself. I hate seeing code and then copying it word for word.
I'm in complete agreement with Servant of the Lord - Google key words related to the concept. You'll usually hit an old post, blog, or tutorial discussing it.
It's not even to "copy working code" - You're bound to find the explanation written out somewhere. If you use the MSDN, you'll at least find a boring but accurate description of methods and their uses, too. The education catalog has pretty well-documented samples that explain what happens in each block and why it's necessary.
Programming is about understanding new concepts, not simply picking up a new command to use. It does take time and a lot of re-reading - Days or weeks in some cases. It happens to us all, and you might feel like you're not getting anywhere, but you will.
Since the thread is already up, do you want to post a couple examples of things that you're having trouble with?
It's not even to "copy working code" - You're bound to find the explanation written out somewhere. If you use the MSDN, you'll at least find a boring but accurate description of methods and their uses, too. The education catalog has pretty well-documented samples that explain what happens in each block and why it's necessary.
Programming is about understanding new concepts, not simply picking up a new command to use. It does take time and a lot of re-reading - Days or weeks in some cases. It happens to us all, and you might feel like you're not getting anywhere, but you will.
Since the thread is already up, do you want to post a couple examples of things that you're having trouble with?
The best way to learn is to do. C++ and SFML didn't click for me until I started writing my own code. I rigorously copied down the examples. The key here is to change the examples. Experiment with them. Look at, say, an images functions and try them all out. As you read constantly think about how you can apply this knowledge and you'll have it in no time. The only way to learn is to do.
The only way I'm learning good programming habits is to code. I'm slowly figuring out where to apply the single responsibility principle, how encapsulation should be implemented, good design patterns / principles, etc. The only way to actually understand a subject is to rigorously practice in the subject.
The only way I'm learning good programming habits is to code. I'm slowly figuring out where to apply the single responsibility principle, how encapsulation should be implemented, good design patterns / principles, etc. The only way to actually understand a subject is to rigorously practice in the subject.
alright i made this from scratch, but the paddles dont move. anyone know whats wrong?
[source lang="csharp"] protected override void Initialize()
{
// TODO: Add your initialization logic here
KeyboardState state = Keyboard.GetState();
if (state.IsKeyDown(Keys.Up))
{
paddle1Pos.Y -= 3;
}
if (state.IsKeyDown(Keys.Down))
{
paddle1Pos.Y += 3;
}
base.Initialize();
}
///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
ball = Content.Load("ball");
paddle = Content.Load("paddle");
}
///
/// UnloadContent will be called once per game and is the place to unload
/// all content.
///
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
int minY = 0;
int minX = 0;
int maxY = 600 - ball.Height;
int maxX = 1000 - ball.Width;
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
ballPos += ballSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
if (ballPos.X > maxX)
{
ballPos.X = maxX;
ballSpeed.X *= -1;
}
if (ballPos.X < minX)
{
ballSpeed.X *= -1;
ballPos.X = minX;
}
if (ballPos.Y < minY)
{
ballPos.Y = minY;
ballSpeed.Y *= -1;
}
if (ballPos.Y > maxY)
{
ballPos.Y = maxY;
ballSpeed.Y *= -1;
}
Rectangle paddle1Rect = new Rectangle((int)paddle1Pos.X, (int)paddle1Pos.Y, paddle.Width, paddle.Height);
Rectangle ballRect = new Rectangle((int)ballPos.X, (int)ballPos.Y, ball.Width, ball.Height);
if (ballRect.Intersects(paddle1Rect))
{
ballSpeed *= -1;
}
base.Update(gameTime);
}
///
/// This is called when the game should draw itself.
///
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(paddle, paddle1Pos, Color.White);
spriteBatch.Draw(ball, ballPos, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
[/source]
[source lang="csharp"] protected override void Initialize()
{
// TODO: Add your initialization logic here
KeyboardState state = Keyboard.GetState();
if (state.IsKeyDown(Keys.Up))
{
paddle1Pos.Y -= 3;
}
if (state.IsKeyDown(Keys.Down))
{
paddle1Pos.Y += 3;
}
base.Initialize();
}
///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
ball = Content.Load
paddle = Content.Load
}
///
/// UnloadContent will be called once per game and is the place to unload
/// all content.
///
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
int minY = 0;
int minX = 0;
int maxY = 600 - ball.Height;
int maxX = 1000 - ball.Width;
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
ballPos += ballSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
if (ballPos.X > maxX)
{
ballPos.X = maxX;
ballSpeed.X *= -1;
}
if (ballPos.X < minX)
{
ballSpeed.X *= -1;
ballPos.X = minX;
}
if (ballPos.Y < minY)
{
ballPos.Y = minY;
ballSpeed.Y *= -1;
}
if (ballPos.Y > maxY)
{
ballPos.Y = maxY;
ballSpeed.Y *= -1;
}
Rectangle paddle1Rect = new Rectangle((int)paddle1Pos.X, (int)paddle1Pos.Y, paddle.Width, paddle.Height);
Rectangle ballRect = new Rectangle((int)ballPos.X, (int)ballPos.Y, ball.Width, ball.Height);
if (ballRect.Intersects(paddle1Rect))
{
ballSpeed *= -1;
}
base.Update(gameTime);
}
///
/// This is called when the game should draw itself.
///
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(paddle, paddle1Pos, Color.White);
spriteBatch.Draw(ball, ballPos, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
[/source]
thanks. those are the kinds of things that help me learn. books dont really explain that
I managed to make a pong game but with no ai. Where do i go from there?
Another chance to post my famous list. Hold, please.
EDIT: Here we go.
The reason for this list is because you know how these games work. The rules and how all the parts are supposed to work. So it's easy to go down the list and learn new skills as you complete each game. For a really good tutorial on 2D game development, google for Lazy Foo SDL
EDIT: Here we go.
- Pong
- Breakout
- Space Invaders (credit to GearSlayer360)
- Missile Command
- Asteroids
- Tetris
- Pac-Man
- Tic-Tac-Toe (credit to 3Ddreamer)
- ????
- Make Money
The reason for this list is because you know how these games work. The rules and how all the parts are supposed to work. So it's easy to go down the list and learn new skills as you complete each game. For a really good tutorial on 2D game development, google for Lazy Foo SDL
breakout is easy enough. i made that in java and C++. i tried snake after that but failed space invaders would be a challenge because you have the shields that protect you from enemy bullets, and a whole array of enemies that move together. and lets not forget the actual process of shooting a bullet which i never understood
and lets not forget the actual process of shooting a bullet which i never understood
I don't consider this a programing or api knowledge problem. I see this as an imagination problem. It's just like a puzzle, but harder one. You have certain elements( types like float, int, in xna case also Vectors, containers like lists, you can create your own classes and structers), only thing is to think of how to combine this pieces of puzzle into whole.
As I always suggest, piece of paper is your best friend. Draw your problem (in case of shooting you got a plane/vehicle and a bullet). Write what defines a plane and what defines a bullet(position, velocity etc.). Draw some vectors (for instance, from plane in shoting direction). Search for relations, experiment. If you won't try you won't accomplish a thing
The most importan thing of all is to never give up
I learned basics of xna from http://rbwhitaker.wikidot.com/xna-tutorials , maybe it will help you too ;)
I managed to make a pong game but with no ai. Where do i go from there?
But the comment above initialise would have when the game1.cs file is generated. Have a look at the comments above the functions in the main game class after creating a new XNA game from the wizards. They say when and how often they are executed also the //TODO comments kind mention what you should do in them.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement