Portfoliosite Joris van Leeuwen:
http://softlion.nl/joris/portfoliosite/?page=projects
Porftoliosite Kevin Wilmink:
http://kevinwilmink.nl
Books for XNA:
http://shop.oreilly.com/product/0636920013709.do
donderdag 24 januari 2013
Eindopdracht
The last excerise is building a (very) small game. We split this game into 4 layers:
Niveau 1:
Class Player: beweegt dmv keyboard
Class Enemy: beweegt door het scherm
Niveau 2:
Enemy heeft een 'random-movement' algoritme. Maak gebruik van states/enums
Niveau 3:
Player en Enemy hebben collision
Collision handling mag in de Game1 class
Op een collision: restart game
Niveau 4:
Ga los en voeg elementen naar keuze toe!
also see the slides:
http://www.kevinwilmink.nl/Seminar/Eindopdracht.ppt
Scope & Enums
We talked about the scope of a variable or method.
In short this means how long a variable 'live'.
We also talked about enums and state machines.
In short a enum is a boolean with additional states
for example:
public enum unitState {
IDLE,
DEFENSIVE,
AGGRESSIVE
}
See the link for the slides from the lessons:
scope:
http://www.kevinwilmink.nl/Seminar/Scope.ppt
Enums:
http://www.kevinwilmink.nl/Seminar/Enums.ppt
Notepad assignments in class:
http://softlion.nl/programmingprinciples/EnumHints.txt
In short this means how long a variable 'live'.
We also talked about enums and state machines.
In short a enum is a boolean with additional states
for example:
public enum unitState {
IDLE,
DEFENSIVE,
AGGRESSIVE
}
See the link for the slides from the lessons:
scope:
http://www.kevinwilmink.nl/Seminar/Scope.ppt
Enums:
http://www.kevinwilmink.nl/Seminar/Enums.ppt
Notepad assignments in class:
http://softlion.nl/programmingprinciples/EnumHints.txt
vrijdag 18 januari 2013
Homework: Inheritance
Like we discussed in the les, the homework is to make the following inheritance structure:
The Game1 contains 2 objects:
The Game1 contains 2 objects:
- Player (which is derived from Sprite)
- Enemy (which is derived from Sprite)
Sprite has a method called 'Update()' this method moves the sprite to the right.
Player also has a method called 'Update()' When this function is called let the player move-up, but also keep the original functionality from the sprite:Update() intact.
The same goes for the Enemy but the enemy should move-down.
In all the update() methods don't let the image move out of the screen, create code that when this occurs the image is teleported back to the other side of the screen (Like we did in the les)
The result should do the following:
Also write your code readable, use const for the right vars, or den your methodes etc.
Some additional challanges:
- Add GameTime as a parameter to the Update()-method ( 'Update(GameTime gameTime)' ) and use gameTime to let the images move at the same speed regardless if the the game has a frame drop.
- Create an additional class named 'Boss' this class derives from 'Enemy'. The 'boss' moves more quickly as the Enemy.
- Save all objects in Game1 as Sprite - objects and see if this still works. Also experiment with this.
- Give the player a new variable named: HitPoints. If the player hits a Enemy/Boss: subtract 1 hitpoint and make the player immune for upcomming damage for 2 seconds. If hitpoints is <0 delete the player object.
Inheritance
Inheritance is deriving a class from another class.
In this example Dogs, Cats and Humans all have the same functionality as Mammals has. However Dogs and Humans (possible) have some unique functionality.
Lions, Tigers and Leopards all inheritance their functionality from Cats (so also from Mammals) and (possible) have some unique functionality themselves.
In this example both the player and the enemy derive from Sprite, (sprite is responsible for drawing the image on the screen). If the method (for example) 'Update' is called upon the player. The compiler first search for Update() in player. If it can't find 'Update()' in player it will search 'update()' in it super class (in this case the sprite class).
Duo this mechanic it is possible to derive from a class and override a method completely or you can choose to override a method but still call it base/super-method.
A simple inheritance structure example
class Sprite{
public Sprite(){
//basic constructor
}
public void Update(GameTime gameTime){
//basic update
}
}
class Player:Sprite{
public Player():
base(){
//player derives from Sprite, if it constructor is called it will also call the constructor from sprite
}
public override void Update(GameTime gameTime){
base.Update(gameTime gameTime); //if Update(gameTime) is called in player, this method also calls the update in sprite
}
}
Also i like to provide the link to the slideshow:
http://www.kevinwilmink.nl/Inheritance.pdf
http://www.kevinwilmink.nl/Inheritance.pdf
donderdag 17 januari 2013
Homework: Mke it redablle!
Hey guys,
Homework for readability was to make an unreadable project readable with all the tricks we've learned you in mind. Use the slideshow I uploaded earlier on this blog as a reference.
Here's the zip file containing the unreadable XNA project. Just open the .sln file and you are good to go!
www.softlion.nl/programmingprinciples/Unreadable.zip
Keep in mind this is not the only homework. We also expect the inheritance practices.
Homework for readability was to make an unreadable project readable with all the tricks we've learned you in mind. Use the slideshow I uploaded earlier on this blog as a reference.
Here's the zip file containing the unreadable XNA project. Just open the .sln file and you are good to go!
www.softlion.nl/programmingprinciples/Unreadable.zip
Keep in mind this is not the only homework. We also expect the inheritance practices.
Readability Slideshow
Hey guys,
Last lesson we talked about readability. Here are the slides of the presentation I gave.
I also added a additional slide for class-ordering with small descriptions like you guys asked.
softlion.nl/programmingprinciples/Les3_Readability.pdf
Last lesson we talked about readability. Here are the slides of the presentation I gave.
I also added a additional slide for class-ordering with small descriptions like you guys asked.
softlion.nl/programmingprinciples/Les3_Readability.pdf
donderdag 10 januari 2013
Ownership and Reference
So the first two lessons we talked about ownership of variables (instances) and also about referencing the ContentManager instance to the Sprite instance in order to use it to load a texture within that sprite. We made a quick paint class diagram to display an overview of what is happening.
Also notice how the Game is unable to directly acces the position and texture variables because they are OWNED by the Sprite class - Can't touch this ! :D
Also notice how the Game is unable to directly acces the position and texture variables because they are OWNED by the Sprite class - Can't touch this ! :D
Sprite.cs
This is the Sprite class we programmed in the second class of Programming Principles.
Pay attention to the encapsulation of the variables. No variable is public (directly accesable) and they are only editable and accesable through the Operator and Get methods.
Link to the Sprite class: http://softlion.nl/joris/ProgrammingPrinciples/Sprite.cs
If you are going to use the Sprite class linked here for you own XNA project, make sure you correct the namespace.
Pay attention to the encapsulation of the variables. No variable is public (directly accesable) and they are only editable and accesable through the Operator and Get methods.
Link to the Sprite class: http://softlion.nl/joris/ProgrammingPrinciples/Sprite.cs
If you are going to use the Sprite class linked here for you own XNA project, make sure you correct the namespace.
woensdag 9 januari 2013
Hello World
If you guys are here for the seminar Programming Principles by Kevin Wilmink and Joris van Leeuwen, then you typed in the correct URL :D
In this blog we will be posting lesson material such as dia slides and source codes.
In this blog we will be posting lesson material such as dia slides and source codes.
Abonneren op:
Posts (Atom)