In this paper, we present work carried out by GreTICE, a University of Girona research group specialising in information technology and communication in education, which is involved in the design and creation of a serious game called "Legends of Girona" to be used in the classroom as a teaching resource. This game has been created in collaboration with GiLab (Graphics & Imaging Laboratory), which is also based at the University of Girona. The game is aimed at pupils between the ages of 10 and 16 (i.e., from late primary school to the first cycle of secondary school. The project evolved from CONTIENE (Content Intelligent Applications of Virtual Reality. Technical perspective and global illumination - TIN2007-68066-C04-01) which was funded by the Ministry of Education and Science (MEC) as part of the National Plan for information technology. This project developed into a new one, TIN 2010-21089-C03-01 entitled "Digital content for serious games: creation, management, rendering and interaction" (CICYT-MEC). In educational terms, the objective of the project is to study the use of videogames as an entertaining teaching resource. We conducted a study into the preferences of young children and teenagers in order to get data that would be useful for the design of the game. From the analysis of the responses, a comprehensive report was prepared that indicated how the game could be improved. The chosen theme was the Legends of Girona, based on traditional stories from the city. The main character in the game is able move between present-day Girona and medieval Girona, and takes part in different adventures in the context of each legend. This idea allowed us to develop a motivating proposal (with adventures, movement in open spaces, interaction with the scenario, etc.) that meets educational objectives that are both general (decision-making, problem-solving, resilience, concentration, etc) and curriculum-specific (history of medieval Girona, French invasions, etc.). With these ingredients, we began to write a script that would form the backbone of the game. Based on the script, the technical team began to make a number of decisions regarding, for example, the game engine, the 3D representation of present-day and medieval Girona and the application of the advances they have made in their research into lighting applied to video games. From that point forward, the pedagogical team and the technical team have worked in parallel and in constant coordination leading to the completion of the graphic design and 3D modelling of characters and scenes, the 3D reproduction of Girona, the character movements, soundtrack, recorded dialogues and the implementation of all these elements into the game engine. After a process of internal testing and reviews, we carried out a small survey to test the degree of satisfaction among players who tested a beta-version of the game. The initial assessments are very positive. The full text of the paper gives more details on the analysis of the data.