different way of learning

Started by
30 comments, last by ChristianFrantz 11 years, 5 months ago
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.

I'm a game programmer and computer science ninja !

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here !

Advertisement
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();
}

/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
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<Texture2D>("ball");
paddle = Content.Load<Texture2D>("paddle");
}

/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}

/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
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);
}

/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
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]

If you see a post from me, you can safely assume its C# and XNA :)

You put your keyboard polling within Initialize. Initialize is not called every frame, you would want that in Update.
thanks. those are the kinds of things that help me learn. books dont really explain that

If you see a post from me, you can safely assume its C# and XNA :)

If I had to guess, I would say it is because the code for moving the paddles is located inside Initialize(), which is only called once (I would hope, otherwise it needs a new name).


[EDIT]
I idled for a while before replying.
[/EDIT]


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I managed to make a pong game but with no ai. Where do i go from there?

If you see a post from me, you can safely assume its C# and XNA :)

Another chance to post my famous list. Hold, please.

EDIT: Here we go.

  1. Pong
  2. Breakout
  3. Space Invaders (credit to GearSlayer360)
  4. Missile Command
  5. Asteroids
  6. Tetris
  7. Pac-Man
  8. Tic-Tac-Toe (credit to 3Ddreamer)
  9. ????
  10. 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

Beginner in Game Development?  Read here. And read here.

 

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

If you see a post from me, you can safely assume its C# and XNA :)


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.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

This topic is closed to new replies.

Advertisement