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 - man'O'war

Pages: [1] 2
1
Graphics / Estabish a rendering order within a same entity
« on: March 02, 2017, 04:07:14 pm »
Hello,

I've recently started using the Quad Tree in order to render the objects of the scene, which makes it a bit dependent on the physical location of the objects, isn't it ?
Closer objects are drawn in front and  farther object are drawn into the back side.

Beside that, i've added a Layer attribute to the objects to create a discrepancy between them. Each one on its own level. ( layer ).
This is perform by creating as many quad_tree as the total number of existent layers.
Now before exposing the problem that i am facing: here is the render call sequence 

void Scene::draw(){
    //  decl: std::vector< quad_tree* > quad_heads;

    for( int i=0; i<static_cast<int>(GoLayer::LayerCount); i++){
        gdf::kernel::GameInfo::game_info->sf::RenderWindow::draw( *(quad_heads[i]) );
    }
}
 

Every QuadTree node's content holds a pointer to the GameObject to draw.
The QuadTree is generated when the Scene is updating all GameObject. ( Hierarchical Tree structure )
void Scene::update(sf::Time dt){
    // .......
    if( !root_.expired() ){

        for( int i=0; i<static_cast<int>(GoLayer::LayerCount); i++){
            // PS1
            quad_heads.resize( static_cast<int>(GoLayer::LayerCount) );
            quad_heads[i] = new quad_tree( AABB(sf::Vector2f(500,500), sf::Vector2f(500,500) ) );
        }

        root_.get()->update(dt);
    }
 

PS1: The reason here. Is that i am deleting and recreating the quad tree structure every iteration ( I don't know if it is the right way to do it )

When update method is invoked on the GameObject (root_). It will recursively build the QuadTree based on the Layer value of the GameObject accordingly.

void GameObject::update( sf::Time dt ){
    // .....
    scene()->quad_heads[ static_cast<int>(layer_) ]->insert( QuadTreeNode<GameObject>( position, this  /*pointer_to_go*/) );
}

 

What if i want to create a specific rendering logic,
For example, within the same entity ( Entity here refers to a sub-hierarchy of game objects ).
I want to make a specific rendering order totally independent from the positioning of the sub-gameobjects.

Here is a schematic

This diagram represents the physical location of the GameObject within the scene.



This diagram is the Hierarchical Tree for the same structure ( Used for updates )



As for this one, is the QuadTree generated.

In @Diag 1, the entity here covers all the objects within the blue dashed square. having as a parent object n°1.

Now the situation is : If the logic says: object n°3 must be on top of object n°1. and somehow, the texture/sprite of the object n°3 is big enough to interlace with n°1's texture. In this case using the QuadTree rendering policy, the object n°3 will be behind the object n°1 ( due to positioning criteria ).  Same for n°1 and n°5 ( with opposite context ).

My point is, i want to make beside the QuadTree rendering policy, a relative rendering order within the same Entity.

Hope the idea was clear.
Cordially.

2
Audio / Re: Cannot load a sf::SoundBuffer
« on: February 23, 2017, 07:10:07 pm »
In fact yeah, that was something that.
I managed to extend the lock memory limit and even change the priority and permission. ( tested using ulimit -a )

related link: https://software.intel.com/en-us/blogs/2014/12/16/best-known-methods-for-setting-locked-memory-size
Thus, removed most of the error i had, except that.

Failed to open sound file "0537.ogg" (couldn't open stream)

tested with other files wav format, still the same. :(

edit:
Got it from here: ( http://en.sfml-dev.org/forums/index.php?topic=20070.0 )
just a wrong path, it is actually wroking.

Thank you very much.

3
Audio / Re: Cannot load a sf::SoundBuffer
« on: February 23, 2017, 03:22:45 pm »
Yes, tested with ubuntu rhythmbox and VLC.
I also reinstalled Ubuntu. and still have the same problem. :(

edit:
Is the issue related to SFML or OS ?

4
Audio / Re: Cannot load a sf::SoundBuffer
« on: February 23, 2017, 11:17:46 am »
How large is the uncompressed version of that sound file?
How can i know that ?
It is a 60kb .OGG file.

5
Audio / Cannot load a sf::SoundBuffer
« on: February 22, 2017, 09:49:02 pm »
Hello,

I encountered some never-seen problem that, i dont know if it is an issue from my computer or not.
By creating a SoundBuffer and loading a file into it, i'll have these messages poping up.

Cannot lock down 82274202 byte memory area (Cannot allocate memory)
Cannot lock down 82274202 byte memory area (Cannot allocate memory)
Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
JackClient::AcquireSelfRealTime error
 

i've looked up trying to restart the jack server, because at first it was telling me the jack server could not be started.

I'm running Ubuntu16.10 using SFMLv2.4.0

Thanks.
Cordially.

6
SFML projects / Re: FLTM (+source code)
« on: February 13, 2017, 04:12:54 pm »
Hei there.
Just for my curiosity, was it inspired from the Blokus board game ?
Gameplay is not similar but still . http://cn.bing.com/images/search?q=blokus&id=2FD05253E4A5D29525B0535FB1FFA0A33BEA8D07&FORM=IQFRBA

Wish you good luck for the rest . ^^

7
General / Re: Need help
« on: August 26, 2016, 12:09:35 am »
Hi,

You can use a matrix to represent links between your dots.

Check this out. (Adjacency matrix ) It is one of many ways of representing links for a graph.
https://en.wikipedia.org/wiki/Adjacency_matrix#Examples

In fact, the implementation of your problem is based on a graph structure.
Where, Circles/dots are nodes and lines are Links.

I suggest you read some tutorial about that, it will make it very easy to implement your game.

Goodluck

8
It's often better to be able to overlap controls than have to force a player to release one direction before pressing a new one. Maybe the best "solution" is to use the most recently pressed direction.
It is definitely related to the game-logic. physic-based games, simple platformer etc. In each case you interpret it accordingly.

Quote from: Hapax
This could then create a "longer" character - maybe to be able to catch something :D
Hahaa.

9
Quote from: Hapax
@man'O'war, I don't think your solution is particularly player-friendly. Sometimes, a player may press both keys (for example, left and right) at the same time. Expected results could be that they cancel each other out and don't move in either direction, maybe just continue in the direction that was pressed first, or even change direction to the newly pressed key. However, its unintuitive to always travel in a predetermined direction based on which key is detected first without any valid reason. Always travelling right when both left and right are pressed makes no sense.
That is true, first condition prevails.

Quote from: Hapax
Always travelling right when both left and right are pressed makes no sense.
Pressing left & right at the same time either makes no sense, it's is the player's fault. :P

Quote from: Hapax
@emersonalbertdomingo, might I suggest something similar to this:
https://github.com/Hapaxia/BringItBack/blob/b8fab970d1cd01a9979d651e178a824195b49013/functions.cpp#L28-L53
Yes, i see opposite actions are canceled. well done

10
I suggest you separate your if ... elses in two blocks,
Trying to move your character up and down at the same time makes no sense, same for right and left.

Each two opposites actions will figure in the same condition-block, its either this or that but never both
And this will permit to detect 'up to 2 keys-pressed simultaneously' (D or A) and (S or W ) or one of them or nothing of course.

However, it may not be suitable for such : playerDirection variable like in your code. unless you split your playerDirection in two, playerDirection.x and playerDirection.y ( sf::vector2 )

Here is the code if you can adapt it:
if( sf::Keyboard::isKeyPressed(sf::Keyboard::D) ) {
        mainPlayer.playerDirection.x = direction::right;
    cout << "right";
}else if( sf::Keyboard::isKeyPressed(sf::Keyboard::A) ){
        mainPlayer.playerDirection.x = direction::left;
    cout << "left";
}

if( sf::Keyboard::isKeyPressed(sf::Keyboard::W) ) {
        mainPlayer.playerDirection.y = direction::up;
    cout << "up";
}else if( sf::Keyboard::isKeyPressed(sf::Keyboard::S) ){
        mainPlayer.playerDirection.y = direction::down;
    cout << "down";
}
 

11
SFML projects / Re: GDF - GameDevFramwork
« on: August 24, 2016, 03:31:30 pm »
Hi,

The Github repo has been updated. including the README.
  • Under kernel branch: You'll find the kernel code almost completed
  • Instructions to compile it and get started with a first example
  • Check the README.md and the wiki for more explanation
  • Documentation file is available: 'doc.tar.gz' under kernel branch

12
Window / Re: Multiple Renderwindow support.
« on: August 24, 2016, 07:25:47 am »
Nothing very special, i was thinking about providing the application with a secondary window.

For example: Having Two displays ( windows simultaneously) :
One shows normal object of the scene, and the second shows boosted one of the same scene. ( Like in Box2D testbed, where you can display the AABB, hitpoint, velocity, force array etc .)


Now i'm aware that it is possible, i can consider using it.
Thank you.

13
Window / Multiple Renderwindow support.
« on: August 22, 2016, 11:14:34 pm »
Hi.

I dug a little about this and i found a non answered topic .

Knowing that we can set multiple viewport using sf::View
I was wondering if it is possible to create several non static objects of RenderWindow simultaneously. Is it safe ?

Regarding the refresh of the windows. round-robin policy can be used as starting policy.

thanks.

14
General / Re: Using same textures for different things
« on: August 22, 2016, 09:15:58 pm »
Hi,

I can't really see through your text ... but i am answering according to your question.

You can use a Resource Manager in order to load resource and keep track of them through an id. ( for reuse purpose )

A resource manager loads a resource ( ex: sf::Texture ) and binds it to an id. generally in map container. O(1) complexity
any time you want to use the resource. you can ask the resource manager for it and get it through its id

an example would be.
ResourceManager rm;
rm.load(2, texture1);
rm.load(1, texture2);

sf::Sprite sprt;
sprt.loadFromTexture( rm.get(2) );

// further. you can deallocate an unused ressource
rm.unload(2);
 

15
General / Re: SFML and CMake with Ubuntu
« on: August 22, 2016, 04:35:44 pm »
Try with lowercase package name
sudo apt-get install libx11-dev

From : http://askubuntu.com/questions/131688/unable-to-locate-package-libx11-dev

Worked for me. Ubuntu 16.04

Pages: [1] 2