Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Mortal

Pages: 1 ... 15 16 [17] 18 19
241
General / Re: Help With Space Invaders Style Game Class. Just started SFML.
« on: November 25, 2015, 10:48:26 pm »
you need to make like this:
class Enemy : public sf::Drawable

242
General / Re: problem wih Pseudo 3D for car-racing
« on: November 25, 2015, 03:51:44 pm »
thanks Hapax for your time

Quote
I think "curve" here refers to the curvature of the road, rather than an interpolation curve.
sorry, i'm not so familiar with mathematics terminology, whats the difference between the curvature of the road and an interpolation curve. i have read other tutorial now regrading mode 7, it explain the mathematics under hood  this kind of game. it seems this subject is away complicated more it looks.

Quote
To change the way the track is drawn based on the where the car is, you could try:
1) offsetting (horizontal) positions before projection (if you're projecting depth), or
2) offsetting all position by a set amount (or just moving the view for the track).
i believe this what update() is doing. it advances the camera view position by certain amount it either moves forward (vertically) or moves aside (horizontally). before the projection. the projection is the final step before drawing it in screen.

Quote
The easing part of that tutorial is about transition from straight road to fully cornered road.
yes .. you are absolutely right. i figured it out after posting my question.

Quote
The code line in your original post is to determine the player's horizontal position on the road.
here where i'm stuck now. when i added this code line to update() function it start jarring and it won't do what it supposes to do. in javascript every thing works fine but in c++ all sorts of abnormality are happening every time.

243
General / Re: problem wih Pseudo 3D for car-racing
« on: November 24, 2015, 11:02:26 pm »
thanks @Jesper Juhl for links

i have fixed jarring behavior in curves, i was calculated camera depth wrongly. the correct calculation should be like this:

Game()
...
, mCameraDepth(1 / std::atan((100.f / 2.f))) //fov = 100.f
...

no need to convert it to radain as tutorial suggested. but the problem is how to make car position (camera x position) reacts with direction of curve. for example when curve is turned to right-hand the player position (camera x direction) goes to left smoothly and vise-versa. the formal for adjust camera position as in tutorial won't work in the my code. i have edit the code in respo and comment the formal for `playerX` in update function to find better solution for it.

244
General / problem wih Pseudo 3D for car-racing[SOLVED]
« on: November 24, 2015, 05:11:23 pm »
hello

i have made small car-racing game by implementing Pseudo 3D based on tutorial in here http://codeincomplete.com/posts/2012/6/24/javascript_racer_v2_curves/.
the code runs fine but when i implemented the curves the car always stuck in middle. how can i fix this?

i want car drafts to opposite direction of curve's direction to give realistic view of this kind of games. in the tutorial, it suggests to use "easeIn()" and "easeInOut()" and adjust the player position like this
playerX = playerX - (dx * speedPercent * playerSegment.curve * centrifugal);

but those don't work correctly in my code. beside the tutorial doesn't explain the curves very well, it seems the author missed vital details in this section.

245
SFML projects / Re: Screenshot Thread
« on: November 22, 2015, 04:36:55 am »
i would like to share my work progress on race cars project. finally i'm able to draw the road. here the picture of the project:



246
SFML projects / Re: Space Invaders Clone - Game finished
« on: October 29, 2015, 12:49:43 am »
such most people are probably interested in how they're affected as a player ;)

thanks Nexus for the advice, sure i will keep that in my mind. the project has finished, it was like my homework  assignment after reading SFML Development Book. i just i wanna try to make little game by my own. whole project even it is for beginner is quite massive for me. most of these minor details were took alot of time from me too as well to grasp and implement them on this project. btw, this is my first graphic game. most of games that i have made was an ascii like hangman, tictacteo etc.

any way, thanks once again for your patient i really appreciate it most.

247
SFML projects / Re: In Soviet Russia
« on: October 25, 2015, 09:33:44 pm »
it looks really awesome. but is it 3D ? if not, how is that possible?

248
SFML projects / Re: Space Invaders Clone - Game finished
« on: October 24, 2015, 12:59:43 pm »
update

- removing old InvadersController class.
- adding a new Invaders class.
- now invaders move faster if one of them get killed.
- adding Generic Random class by using c++14 feature.
- implement type checking for template (functions, class)
- eliminate incidental control flow and implement correct tool from STD algorithm header in Invaders class.
- fixed bug, some time the game doesn't end when all invaders killed
- cleanup
 

249
SFML projects / Re: Space Invaders Clone - Game finished
« on: October 22, 2015, 09:12:55 pm »
thanks Hapax

i did what you have told me to do in earlier post, like player's behavior and bullets fire rate. the only left from what you have observed from first attempt is invaders movements where lowest row moves first then the one above until it reaches the most top row just like what is in the link that you gave it. i was attempting to wrap my head around this whole thing but i couldn't even it sounds like easy to implement.

250
SFML projects / Re: Space Invaders Clone - Game finished
« on: October 13, 2015, 04:29:11 am »
update

- re-write QuadTree class, now it is much readable
- re-write the helper function 'derivedAction' in Command class, by using SFINAE instead of dynamic_casting
- adding PlayerFactory Class for managing its spawning
- adding BossFactory class for managing its spawning
- adding GameConstants file for common constant variables
- fixed a bug where the button's sound always peep twice when user navigates throughout buttons by the mouse
- more clean up

251
SFML projects / Re: Red Plane (Rotes Flugzeug) - new version
« on: October 09, 2015, 09:09:36 pm »
hi
it looks nice game. i like it.

i have looked your code. i think there are many things you may need to do. i recommend you to try this site codereview.stackexchange.com to give you better code review.

however. i will briefly review your code, btw, i'm still beginner i just learnt c++ last years. :-\. for comprehensive code review check the site above.

in your Enemy class
- it is better to put a class declaration and definition in two separate files like .cpp and .h or .hpp.

- it's preferable to use float for position and time calculation rather than int.

- use const for member data that won't change throughout game like speedPerSecond, maximumDistance

- no need for "this->" pointer, you may use Constructor initialization lists  for members data

here Enemy class after modification:

Enemy.h
#include <SFML/Graphics.hpp>

class Enemy final : public sf::Drawable
{
public:
        Enemy(const sf::Texture& texture, float posx, float posy);

        // usually the member function start with small letter in c++
        // also, it uses in SFML
        void update(float speedX, float timeDelta);

        sf::FloatRect getGlobalBounds() const;
        bool isAlive() const;


private:
        // draw can be declare as private
        void draw(sf::RenderTarget &target, sf::RenderStates states) const override;


private:
        // there are many style guides for c++ most known and widely uses is camelCase
        // for member data. personally i like camelCase over snake_case. in Both of them thay
        // used 'm' prefix to indecate the data is member data like below
        sf::Sprite              mSprite;
        const float             mSpeedPerSecond;
        float                   mDistanceTravelled;
        const float             mMaximumDistance;
};


Enemy.cpp
#include "Enemy.h"

Enemy::Enemy(const sf::Texture& texture, float posx, float posy)
        : mSprite(texture)
        , mSpeedPerSecond(20.f)
        , mDistanceTravelled() // by default is zero
        , mMaximumDistance(472.f)
{
        mSprite.setPosition(posx, posy);
}

void Enemy::update(float speedX, float timeDelta)
{
        auto distanceTravlledThisUpdate = mSpeedPerSecond * timeDelta;

        mDistanceTravelled += distanceTravlledThisUpdate;

        mSprite.move(speedX*timeDelta, distanceTravlledThisUpdate);

        if (mSprite.getPosition().x > 1600)
        {
                mSprite.setPosition(-800, mSprite.getPosition().y);
        }
        if (mSprite.getPosition().x < -800)
        {
                mSprite.setPosition(1600, mSprite.getPosition().y);
        }
}

sf::FloatRect Enemy::getGlobalBounds() const
{
        return mSprite.getGlobalBounds();
}

bool Enemy::isAlive() const
{
        return mDistanceTravelled < mMaximumDistance;
}

void Enemy::draw(sf::RenderTarget &target, sf::RenderStates states) const
{
        target.draw(mSprite, states);
}


in Game class
it should be separated in .cpp and .h files

you may use std::unique_ptr instead of std::share_ptr.
std::unique_ptr<Enemy> eEnemy(new Enemy(enemy, posx, posy));
enemies.push_back(std::move(eEnemy));

i don't really like loop inside loop for the vector of enemies in this snippet
for (auto i = enemies.begin(); i != enemies.end(); i++)
{
        if (!(*i)->IsAlive())
        {
                // no need for loop whole enemies vector in here
                enemies.erase(std::remove_if(enemies.begin(), enemies.end(), [](const std::shared_ptr<Enemy>& o) { return !o->IsAlive(); }), enemies.end());
                hitTheGround++;
                enemiesLeft--;
                break;// <-- maight be a bug
        }
        else
        {
                (*i)->Update(speedX, timeSinceStart.asSeconds());
        }
}

it would be much easier if you just make it like this:
for (const auto& enemy : enemies)
        enemy->update(speedX, timeSinceStart.asSeconds());

enemies.erase(std::remove_if(enemies.begin(), enemies.end(),
        [this](const std::unique_ptr<Enemy>& o)
{
        if (!o->isAlive())
        {
                hitTheGround++;
                enemiesLeft--;
                return true;
        }
        else
                return false;
}), enemies.end());


why you call collision() multiple times in game-loop, only one call is enough.
backgroundLoop();
collision();
render();
createBullet();
collision();
createEnemies();
collision();
processEvent();


also, no need for "enemiesLeft" you can check the enemies left by vector size. i don't know if your compiler support std::to_string(), if so, you can use it like this:
showEnemiesLeft.setString("Enemies left: " + std::to_string(enemies.size()));


and there are more but for time being it is better to concentrate on code styling and files organizing

252
SFML projects / Re: Space Invaders Clone - Game finished
« on: October 04, 2015, 08:03:30 pm »
update

- upgraded to latest sfml version 2.3.2.
- reduced the death animation interval for player
- add LifeNode class
- add ScoreNode class
- add InvadersController class
- add green bottom line to SpriteNode class
- major clean up and code-style

253
SFML projects / Re: Space Invaders Clone
« on: October 01, 2015, 09:33:39 pm »
i added video to latest update



update
- player can spawn after its death
- whole screen freeze while player animating death and game resume after player recreated
- player bullet only fire when current bullet is destroyed (no more fire rate in the game)
 

254
SFML projects / Re: Witch Blast (dungeon crawl shooter)
« on: October 01, 2015, 04:40:53 pm »
amazing, good job. i like the graphics and effects. the most i like the inventory screen , it looks really fabulous

255
SFML projects / Re: Space Invaders Clone
« on: September 30, 2015, 02:49:19 pm »
added new video for latest updates on the main post.

Latest update
- new movement pattern to invaders block by implementing simple state-mechanism
- implement dirty flag efficiently
- implement fixed time-step in game loop
- boss can spawn and entering the scene occasionally
- new bullet texture
- bullets can collide with each others
- fixed the bug where the block of invaders suddenly drop down



Pages: 1 ... 15 16 [17] 18 19
anything