AI & structure

Hello!

So this week I have been working on the following AI and a better way to draw the rooms that the map are currently creating.

The first I did this week was start with a AI for our enemy number 2. But the as I have progressed slowly in the work and we are going to show an alpha this Friday (tomorrow). I decided to change my priority work this Wednesday.

As of now that might have been to late and I shall now proceed to tell you about the two.

AI

How will our AI work for enemy 2?
AI for enemy 2 will do the following. He will walk a path between 3 nodes like below.

AI_descrip

It will then detect if a player is inside its radar like the circle above.
As a player enter the circle the enemy will start to attack the player by moving towards him and then shooting out its deadly tongue towards the player.

To make it more life like it will then move a half of a half circle around the player and shoot again.

So this should be simple in SFML right? Just create a circle using sf::CircleShape; for detection and then create the sprites and use them

This is however were the code went tricky. When searching for a ”simple” detection algorithm it suggested that I use the circles radian and Pythagoras calculation in order to calculate if something was inside the circle. Upon doing that several setbacks happened.
1. The sprite disappeared  … and we could not find why.
2. The Circle and Sprite then stopped moving.
3. The Attack state (that should be triggered when you enter the circle as a player) did not trigger.

Well after that I did more research and ended up with a lot of things that needed to be tested. Not something I would manage to create before the show of our Alpha.

So I decided to change my work to something more productive.

Creating a map

So I decided to create the level and make doors that go *swoosh* when you go through them. BUT! I ended up with a snag. Yesterday I took a look at our so called code and saw a giant flaw in it.

It’s messed up.
We are drawing our ship with set coordinates and set room spaces and use a tile over and over again. This is not a good option since you can’t actually really see how the Rooms should be created. I was at a loss, so I went to bed early so I could start work earlier.

after sleep

I could not see how the rooms are positioned in my mind and that’s a problem.
I decided to create a map1.txt file that looks like this:

map_txt_layout

0 being outer space and 1 being the rooms.

 

This would read the file and then decide upon that how the tiles were set. Then after starting to do this realization came, how are we currently handling so that the character can’t walk out of a room.

A Room class had been created that handled this perfectly, however to be able to walk between rooms they have to be active. As far as I can tell right now.

The rooms them self have a set length and use a setTextureRect(sf::IntRect());
In order to create a bigger room. This looks bad when the textures don’t match up.

They also need something ”like a door” between them in order to walk between them.

And I went to a standstill again. I am currently writing this blog because I think I will have to work a lot this evening and won’t have time to write it then, so I can’t come with a real answer to how or when this problem will be solved but I can tell you one thing:

Our code needs better structure and we programmers need to communicate better in our group.