Beginning programming students face a number of learning difficulties due to a multiplicity of theoretical and technical new concepts in program construction and algorithms, which often lead to their lack of motivation to learn programming. We have developed pedagogical learning sequences based on serious games for the module algorithms and programming. We implemented our new method in an experimental class of 20 high-school students. We first introduced serious games to the students, then taught them how to create simple games in a visual environment facilitating programming (Scratch). Twenty other students (control group), followed an introduction to algorithms and programming using a conventional teaching method. Both groups had the same summative assessments as well as a survey to assess their motivation and interest in learning programming. The experimental group not only outperformed the control group but showed better motivation for programming. We conclude that serious games help achieve an effective student learning environment where students build their own knowledge and skills, and motivate them for computer sciences.