Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

March, 2009

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    The Problem with Lists


    Let’s talk about social networking for a minute. For example bloggers and twitter – and related of course but those are the two things I am thinking most about. There are some good lists out there. For example I like Scott McLeod's list of top 50 education bloggers. And I have been scanning through the tag lists at lately. The edtech and education tags in particular. I’m looking for interesting people to follow when I look at those lists. And I do find some. But honestly I think I miss a lot as well.

    I mean sure it is probably a safe bet that someone who makes Scott’s list is writing interesting stuff. After all that list is based on Technorati lists which is based on how many people link to those blogs. People tend to only link to interesting stuff. And the twitter list is based on number of followers. Once again boring people don’t pick up followers. But what about the long tail?

    By the long tail I mean those bloggers and twitter users who are interesting and useful and potentially great but who have not been around for many people to find them yet. These top 50 lists don’t help people find these gems in the rough. Oh sure I might find them if I look far enough down the list of education tagged people in WeFollow. But at 461,000 people (can that be right?) I’m not sure I have time to check them all out.

    For this reason I think we (all of us) need to help people discover new people to follow – be it on Twitter or bloggers or what ever. I love the idea of #followfriday on Twitter. Follow Friday calls for people to recommend other Twitter users for people to follow. Often these come in a theme. It’s all very individual but if is a way of introducing people to others. I think it helps. With blogging there are blog rolls and links embedded in posts of course. These are very helpful and are a long standing tradition in blogging. So maybe when you visit a blog from a Top list you will want to see who they link to. And when you look at a new Twitter feed see who they follow.

    Of course that only works if the top bloggers and Twitterers follow more than just the other top of the list people. I think that is also a good idea, a healthy idea, to prevent getting caught in an echo chamber. In a sense I feel like the A-list bloggers and Twitterers serve their audience best when they widen the circle and bring more people into the conversation. It’s not always how many people read/follow you. Sometimes it is about how wide a circle you are learning from.

    So help me find good people to read (blogs) and follow (Twitter.) And I’ll try to do the same for you. Thanks.

    PS: I’m on Twitter at

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Turning Pro


    I was reading Raymond Chen’s blog post about the NCAA tournament the other day and it got me thinking. Raymond set up his brackets based on the college’s graduation rate for basketball players. Most of those teams graduate fewer than half their players. Not exactly a recipe for success in later life in my opinion. Now I guess if most of those players turned professional it might not be quite so bad. But the fact is that very few of them will actually make a living playing professional basketball. It takes an extraordinary level of both skill and hard work to become a professional basketball player. And of course there are very limited spots open. You can’t go all entrepreneurial and start your own team either. Well I guess you can and there are independent teams that entertain people but really unless you are the Harlem Globetrotters it is not an easy life. On the other hand a good education – including one in computer science – lets pretty much anyone who wants to work hard at it turn professional.

    And last I heard the hi-tech field, even in this economy, is a route to a good career that is open even to people who are not 6 foot 6 with a great jump shot.

    While I am at it, I’ve found myself reminding people that one of the benefits of the Dreamspark (now available for high schools to sign up for on behalf of their students) program is that it comes with the IT Academy Student Pass. That means 12-22 hours of free online training related to Microsoft certification. I hope a lot of people take advantage of that program.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Pong – A Simple hands on lab for XNA Game Studio


    This hands on exercise is based on a demo by Sam Stokes called Pong in Five Minutes. I appreciate Sam’s help in this effort. You can watch Sam’s demo in a video and get the code and other files used in this lab from  If you want these materials more easily available. So I have uploaded them to Skydrive at the links below.

    How To Create A Pong Game in XNA 


    • Step by step instructions
    • Code Snippits
    • graphical content


    Open a new Windows Game Project from the XNA Section for the C# language in Visual Studio 2008.


    Select Content from the Solution Explorer and choose the Add Existing Item option for the Project menu.


    Navigate to where you have saved the image files and add them to the project.


    Set the Copy to Output Directory property of both images to “Copy Always”


    Now we are going to add two classes to do the work of the game. We will add a ball class and a paddle class. First add the Ball class by selecting Add Class from the Project menu. This opens a window where we can name the class Ball.


    Enter the following code for the Ball class.

           class Ball
                //position of ball
                public Point pos;
                public int h_speed, v_speed;
                //constructor - position
                public Ball(int x, int y)
                    pos = new Point(x, y);
                    Random rand = new Random();
                    h_speed = rand.Next(3, 7);
                    if (rand.Next(0, 2) == 0) h_speed *= -1;
                    rand = new Random();
                    v_speed = rand.Next(3, 7);
                    if (rand.Next(0, 2) == 0) v_speed *= -1;

    Now create the Paddle class the same way and enter the following code for the paddle.

        class Paddle
            //position of paddle
            public Point pos;
            public int speed;
            //constructor - position
            public Paddle(int x, int y)
                pos = new Point(x, y);
                speed = 3;

    Add a call to the Microsoft.XNA.Framework libraries to the top of the the Ball and Paddle class files so that these libraries will be available.


    Return to the Game class and define the variables and objects we need for the game.

       public class Game1 : Microsoft.Xna.Framework.Game
            GraphicsDeviceManager graphics;
            Texture2D t_paddle1, t_paddle2, t_ball;
            SpriteBatch spriteBatch;
            Paddle paddle1;
            Paddle paddle2;
            Ball ball;
            Random rand = new Random();
            KeyboardState currentState;
            GamePadState currentPad;

    Now let’s create an UpdateBall class to move the ball around the screen.

            void UpdateBall()
                //update positions
                ball.pos.X += ball.h_speed;
                ball.pos.Y += ball.v_speed;
                //check for boundaries
                if (ball.pos.Y > (Window.ClientBounds.Height - 10 - t_ball.Height))
                    ball.v_speed *= -1;
                if (ball.pos.Y < 10)
                    ball.v_speed *= -1;

    We also need an UpdatePaddles method to control the paddles.

         void UpdatePaddles()
                //get keyboard keys
                currentState = Keyboard.GetState();
                currentPad = GamePad.GetState(PlayerIndex.One);
                //check for up and down arrow keys
                if (currentPad.Triggers.Left > 0.0)
                       paddle1.pos.Y -= paddle1.speed;
                if (currentPad.Triggers.Right > 0.0)
                        paddle1.pos.Y += paddle1.speed;        
                //paddle to move according to ball
                if (paddle2.pos.Y + (t_paddle2.Height / 2) > ball.pos.Y)
                    paddle2.pos.Y -= paddle2.speed;
                else if (paddle2.pos.Y + (t_paddle2.Height / 2) < ball.pos.Y)
                    paddle2.pos.Y += paddle2.speed;
                //check boundaries
                if (paddle1.pos.Y <= 10) paddle1.pos.Y = 10;
                if (paddle2.pos.Y <= 10) paddle2.pos.Y = 10;
                if (paddle1.pos.Y + t_paddle1.Height >= Window.ClientBounds.Height - 10) paddle1.pos.Y = Window.ClientBounds.Height - t_paddle1.Height - 10;
                if (paddle2.pos.Y + t_paddle2.Height >= Window.ClientBounds.Height - 10) paddle2.pos.Y = Window.ClientBounds.Height - t_paddle2.Height - 10;

    In the Initialize method that was created for us automatically we have to add a call to ResetGame to start our game.

            protected override void Initialize()
                // TODO: Add your initialization logic here

    In the LoadContent method we have to add some calls to load the images that we have already added to the project.

            protected override void LoadContent()
                // Create a new SpriteBatch, which can be used to draw textures.
                t_paddle1 = Texture2D.FromFile(graphics.GraphicsDevice, @"content\paddle.png");
                t_paddle2 = Texture2D.FromFile(graphics.GraphicsDevice, @"content\paddle.png");
                t_ball = Texture2D.FromFile(graphics.GraphicsDevice, @"content\ball.png");
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
                // TODO: use this.Content to load your game content here

    Lastly we need to add code to the Update method to call the methods that make the game run.

            protected override void Update(GameTime gameTime)
                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

    Now we can run the game and use the up and down arrow buttons to control the left paddle.


    Note that you can use the Escape key to exit the program as well as the back key on an Xbox 360 Controller.

    Get XNA Information at

Page 3 of 7 (20 items) 12345»