CSE1301 Lab 1 – Intro to PSM

advertisement
CSE1301 Lab 1 – Intro to PSM
Grading




Did not complete lab - 0%
Submitted a minimal solution with major problems - 33%
Submitted a nearly-complete solution with some minor problems - 66%
All tasks completed correctly - 100%
Objectives

Explore how PSM games work and understand the Update and Render methods
Background
As a review, in PSM Studio, look at the Solution Explorer. (View Solution Explorer if it’s
not open.) In it you will see the structure of the solution.


Notice the structure of this solution corresponds 1-to-1 to the file system structure
The References folder includes information of which external libraries are
required to support this application.
We can examine some of the files in our project (double click on the files to open them
in the editor).




The files with the sln extension are called solution files. They describe the
structures of project files.
The files with the csproj extension are called project files. They describe the
structures of source code (cs files) and the building method.
A solution file is the starting point of a project; open this file when starting
development of an application.
Once the solution file is open, build and press the F5 key to execute.
There are some important parts of the default/blank PSM code to note: Main(),
Initialize(), SystemEvents.CheckEvents(), Update(), Render(), and SwapBuffers().


Main() - A program starts with Main(). Any application will always require one
Main() function. If there are two or more, a build error will occur.
Initialize() - The content of Initialize() mainly describes the initialization
processing. This processing is performed only once during startup in this
program framework.





While - Next, a loop is entered with "while". In other words, the
SystemEvents.CheckEvents(), Update(), and Render() processing is repeated
inside.
SystemEvents.CheckEvents() - The OS dependent events will be checked with
SystemEvents.CheckEvents(). An Android device, for example, will detect an
event here where an application is minimized, etc. Window message processing,
etc in Windows will be detected here.
Update() - The calculation processing, etc. handled by the CPU is mainly
described in Update().
Render() - The render processing and calculation processing, etc. handled by
the GPU is mainly described in Render(). In Render(), the frame buffers are first
cleared with graphics.Clear().
SwapBuffers() - SwapBuffers() switches the frame buffers with the vertical
synchronization timing.
We bring in assets into our game by using the content project; these assets are then
available to us in the Initialize function.
Directions
This lab has two parts:
1. Create your own graphical asset
2. Bring these assets into your project and display them in a PSM application.
For the assets part:




Open your favorite 2D art/paint program and create one background art asset
and one sprite/moveable graphical asset.
The background should be of size 960x544 – the default size of the PlayStation
Vita - (or another dimension of your choosing)
The spite asset should be of a smaller size, perhaps 80x80, but the choice is up
to you.
Save these two files in a usable format (PNG, etc.)
Coding:





Create a new PSM application
Establish your game to be of the same size/dimensions as your background
image
Import both art assets into your content project
Using Initialize, bring these assets into your game as Sprite objects
In the render method, make the background paint and then display the sprite in
the center of your game by default. Be careful to make the center of the sprite
appear in the dead center of the game. This will involve a little math.


Add the ability for the user to press the left and right arrow keys to move the
sprite left and right respectively. The sprite must move horizontally in the
application.
Add the ability for the user to press the SELECT (Z) key to close the program.
Challenge
If you feel like it (this is not required), add the ability for the up and down arrow keys to
move the sprite up and down in the game world.
Submitting your project
1. ZIP/compress the entire project file for this solution/application.
2. Submit this ZIP file into the D2L system for this lab in the appropriate lab
assignment location.
Download