Alien two has entered the game.

So we are carefully approaching the creeping doom that is the beta. The zombie model for our game. Maybe doom would be a bit harsh but it is an end we are working towards.

Anyway this week I have been working on implementing our second enemy for our game. The tongue enemy. This enemy is supposed to stay stationary on the map and when a player is within a certain distance it will shoot out its tongue. This tongue will then hopefully or hopefully not for the player attach itself to the player and then retract itself towards the alien. And then the alien will begin to eat the player. This behaviour is similar to the barnacle from the great games called half life.

This enemy works like our first alien enemy. We use our room class for this one as well for reading x and y position and amount of enemies from a text file. These enemies then get the x and y coordinates and gets pushed into a vector. Game state then loads this vector for updating and drawing the enemies to the world.

I wrote previously that they work similar to the first alien enemy but that isn’t totally correct. This enemy have fewer methods in its class as it has no requirement to move towards the player or split into two enemies. And as such it only have the methods for getting it hp and other such things.

blogg alien

So here’s the alien in the game. Painted by our talented lead artist. For now it has another behaviours other than pointing at the direction of the player. But the tongue attack was not complete enough to be shown but will be implemented in future updates. The other behaviour is its attack animation and idle animations. So it engages its attack animation when the player I within a certain range of the alien. For now the range is 500 pixels from the player but we will have to balance that when the tongue is properly implemented but it is a work in progress. Other things to balance is how fast the tongue will be shot at the player and also how fast it will retract. If these are too fast it might be hard to kill it before it damages the player. And also the aliens hp is something we will be thinking about when balancing. But For now there exist a secondary enemy for the player to shoot and be moderately angry or scared at.

Companions need to speak or in this case write.

So this week I have worked on our games A.I companion. That is a type of display or small PDA. This companion is meant to help the player through the game by telling current objectives and other useful information. Most of the companion works but the important part was the text it displays on it’s display.

HAC the A.I display.

So SFML is really handy when it comes to these sorts of things. As it already have classes for fonts and text. First off all I created member functions for sf::Font and sf::Text. And I also found a proper font to use within our project. The font I’m using is called byte police and is free to use for noncommercial uses. I found it at Dafont (http://www.dafont.com/) which is a great site to find free or inspiring fonts. So to start font loads the font from file m_font.loadFromFile(“bytepolice”); and so we have a font to use whit our text. And after that it really simple sf::Text have functions to declare the font to use and other things like size, color and style. So we just set the preferred size and color and after that we draw the text using window.draw(m_text);.

For the A.I companion we read the text from a file but the thing about sf::Text is that it only accepts sf::String and not std::string. So to begin whit we us std::istream and then open the file we want to load from. First we get a single line that contains a number for the amount of lines the document contains. We then loop through these. For this I created vectors one for sf::string and one for sf::Text. As we read the lines in the file we push these back into the sf::vector but converting them to sf::Strings as we do it. We the set m_text to the newly created sf::string and push it back into its vector. What we are left whit is a sf::text vector whit all the text from the file. We then loop through again and print them to the screen using window.draw().

After this in Update we loop through the vector of sf::texts and set their position relative to the PDA thing that they are supposed to be displayed on. But we shift their text downwards for each loop so they appear on new lines.

dave
Here we have an example of the text in action an as the screen move the text will also because we update them individually. This is a simple font and just black standard characters but as sf::Text is a implemented class it has a good amount of features. To give it some more effects or just customize it. But a good font goes a long way.

Last Signal – Player Power Ups.

So this week I have been working on implementing the power ups the player while be able to pick up from the world. This was an important feature we needed to have for our presentation of the alpha version of our game.

The Power ups works whit our Room system that then draws them into our world for the player to collect. The room system is described in better detail at (http://antonclasson.com/2015/02/19/last-signal-room-system/). But described in a few words it would be a text file whit x and y coordinates and other data. The data is the read and drawn into our world. The Power ups are also located in this text document. Whit their own coordinates and power up type.

The different types of power ups is Damage field which allows the player to become invulnerable and damage enemies if a collision occurs. CPR (Compressed Plasma Rounds) that have a higher base damage the players ordinary projectiles. Battery pack that refills the players energy, And Lastly for the alpha build the Repair kit that repairs the player to full health.

All these power ups then get their own colliders that applies an effect to the player depending on the type of power up the player collides whit. As an example the power up damage field sets a invulnerable true/false variable to true. That makes it so the player can’t take damage as long as it’s true. This also triggers a timer to count down. And when this timer reaches zero the invulnerable variable is set to false and also the timer resets. While this timer is counting down the player also gets a new sprite to represent the field that surrounds the player. This is so the player gets a visual representation for the power up. When the timer reaches zero the sprite change back into the original astronaut sprite that was used in the beginning.

picture before

So the one above is the one before pick up the one whit a lightning bolt is the battery pack and the plain one is the Damage field. And Below you will see the Damage field power up in effect.

picture after
When a collision occurs between the player and any power up the power up is then removed from the list of power ups so it disappears in the game. This is the description of a type o power up but the other types work in very similar fashion it applies an effect to the player on collision be it temporary invulnerability or just increasing health to Max. It then disappears from the world and can’t be used again.

The only power up yet not implemented is the Overcharge that gives the player faster fire rate. That sad to say is yet to be implemented as it required some changes to the player class that we didn’t have time to do. But it is not that hard and will be in the game before the beta.

Last signal blogg 1

The last signal.

Så nu har ett par veckor för projektet passerat och vi har nu närmat oss den punkten där det fins något att spela. En av de saker som jag fokuserade på var att ge vår Alien fiende en typ av artificiell intelligens. Det som utvecklade för Alien var mer vad som skulle hända när vissa förutsättningar uppfylldes. Om man skulle jämföra detta med en annan typ av intelligens så skulle den vara väldigt primitiv där den nuvarande Alien inte bryr sig om den blir skadad. Jämfört med något mer avancerat som skulle ta hand om sig skälv eller fly när den tog för mycket skada. Anledningen att Alien fienden inte flyr är att fienden både skulle kännas primitiv samt aggressiv.

Alien har även en annan typ av beteende som gör att den delar sig till flera Aliens när den befinner sig tillräckligt nära spelaren.

Det nuvarande beteendet på Alien är att den väntar på en platts sedan när spelare befinner sig inom ett vist avstånd så rör sig Alienen emot spelaren och försöket ta sig nära nog att skjuta mod spelaren. Samt dela sig till flera Aliens. Om spelaren nu tar sig utanför Alienens skjut avstånd så följer den efter spelaren tills hen befinner sig utanför avståndet. Därefter så slutar Alienen att följa spelaren och sitter stilla på sin nuvarande position.

picture

Här ser vi Alien som en grön fyrkant i mitten. Den röda cirkeln är avståndet spelaren behöver befinna sig inom för att den ska skjuta och dela på sig. Den svarta cirkeln är avståndet spelaren behöver befinna sig inom för att Alien ska röra sig emot spelaren. Samt den blå femhörningen representerar spelaren.

För att se om vilket avstånd spelaren befinner sig på så använder jag Pytagoras sats. Genom att först kolla vilka x och y koordinater som Alien har samt koordinaterna som spelaren har kan vi sedan räkna ut avståndet mellan dessa två punkter.

dist-2-points-e

Genom att sedan ge Alien logiska beslut när ett visst avstånd mellan den och spelaren uppfylls så kan man ge den en typ av beteende.

Dessa logiska beslut gan förenklas ner till.

If player is whitin range

{

Move toward player

If player is whitin shooting range

{

Shoot towards player.

Multiply.

}

}

else

stand still.

Det här är det simpla men fungerande beteende på vår första Alien fiende. I början av projektet så var det planerat att ge den en simplare typ av pathfinding om spelaren befann sig bakom en vägg som den skulle gå runt för att ta sig närmare spelaren. Detta var däremot inte implementerat eftersom Detta var något jag inte tidigare var familjär med samt det var något sov vi inte tidigare har gott igenom på programmerings föreläsningarna. Detta är däremot något som kan bli implementerat i framtiden där Tommi vår lärare har planerat att ta upp detta på en föreläsning.

Men detta var allt för denna vecka.

Nionde Veckan

Denna vecka har arbete med game states och classer för alla objekt varit fokus.

Genom att få en sprite bild att röra sig på vår bakrund vi har valt så har vi tagit steg framåt mot det färdiga spelet. Mer arbete behövs men vi närmar oss ett fungerande spel.

Framöver blir det att lägga till mer classer för varje objekt som ska in i spelet. Samt flera states för spelet. Vi planerade utöver gamestate ett menue state för en introduktions skärm med legend of zelda. Bara så den ser lite fräsig ut.

Title_Screen_(BS_The_Legend_of_Zelda)

Colition är något som ska implementeras även tillsammans med musik och ljud. Men colition är viktigast utöver det andra.

Vi får hoppas att det blir både ett bra projekt/spel och bättre väder framöver.

Trevlig helg.

Åttonde veckan

Jaha mer stress denna vecka med både födelsedagar och nyårs firande.

Hoppas alls hade ett trevligt ny år och att ni har ett lika trevligt 2015.

Så under den här veckan har gamestates varit prio tillsammans med claser för alla objekt som ska bete sig i spel värden. Mycket av det som ska skrivas är gamestatesen samt menue state även ett par av game object states. Det som gällde var att få grunderna klara. Mycket research var gjorda av båda gruppmedlemmarna så det både ska vara enklare att koda spelet och framtida spel.

Nästa vecka åker jag hem och föreläsningar börjar igen det var roligt att vara hemma men det ska även bli roligt att komma hem till Gotland.

Trevlig helg

Sjunde veckan

Under denna vecka har det varit mycket jul stök och andra händelser som tagit upp tid

Det har självklart varit tidigt men eget arbete har blivit fokus under veckan.

Under veckan har jag arbetat med Sprite och SpriteManager samt en enkel variant av gamestate som test grund.

Eftersom det har varit stökigt so har fokus varit att lära sig mer hur ett spel ska struktureras samt hur SDL fungerar lite djupare på sprite ritningar.

Nu framöver blir det mer intensivt grupparbete när vi gör klart det basiska för spelet och jag hoppas att allt ska gå bra. Gott nytt år.

Sjätte veckan

Under den här veckan har vi gått igenom Animation för sprites och sprite sheets. Detta är väldigt bra att kunna när vi kommer till delen av spel projektet där allting ska röra sig och spelar karaktären ska se animerad ut.

Vi gick sedan igenom avancerad kollision som innebär att fundera ut hur sfärer och roterade kuber/trianglar kolliderar mot andra objekt. Detta är bra för personer som gör lite mer avancerade former av koalition. Vi gick även snabbt igenom pixel perfekt kollision som innebär att sprites kolliderar på pixlarna dom är uppbyggda av och inte en ruta som omfamnar spriten.

Under hela veckan spenderades tid på vårt projekt där vi konstruerade en enkel sprite manager och fick vår input manager och keybord att fungera. När sprite och sprite manager är klara förhoppningsvist inom den här veckan så blir det att konstruera ett test gamestate för spelet vi gör.

Jag tog även färjan hem till lilla Kalmar som jag nu ska spendera jul och nyår i innan jag åker hem Nesta år.

God Jul och Gott Nytt år!

Femte veckan

Under den här veckan har vi programerat vidare och slutfört programmet arkanoid . Vi la in kollision och bollens rörelser.

Vi hade även genomgångar på hur man kan lägga in andra filtyper än bmp. Detta leder till att filer kan nu ha Alpha och då ha osynliga bakrunder istället för en helt rosa/lila bakgrund.

Vi hade genomgång på font rendering. Med SDL_TTF så kan man representera text på skärmen. Detta är riktigt bra för spel som innehåller text så som tex legend of zelda.

Jag startade även på Projektarbetet under veckan. Genom att tillsammans med Johannes göra ett design dokument för Legend of Zelda och även börja med det första bitarna av kodning som omfattar att få SDL att fungera.

Fjärde veckan

Den här veckan spenderade vi på att skriva och lära os om SDL och Bas kåden som behövs för att göra spelet Arkanoid.

Detta involverade att skriva ett antal klasser som skulle hantera olika game states och generellt grafiska bitar.

Jag känner att jag behöver göra lite små uppgifter angående SDL för att få lite mer förståelse. Men sakta och säkert lär jag mig mer efter varje lektion även om det är lite mycket att ta in.

Ingen kod denna vecka