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.


Topics - Nybble

Pages: [1]
1
Graphics / sf::Transformable combine
« on: April 01, 2016, 08:51:07 pm »
Hello every one, what I am trying to do is "combine" 2 transforms, but it is not working, it works fine when it collides on all sides BUT the left side of another rectangle... I just think I'm using the combine method wrongly.

Object object; //this is my own "Entity" class which inherits from sf::Transformable and has methods to get "rectangle dimensions"
Vector2f offset(100,100);// arbitrary number in this case
sf::Rect<int> bb;

sf::Transform temp(0,0,offset.x, 0,0,offset.y, 0,0,1);
temp.combine(object.getTransform());

        sf::FloatRect localBounds(0.f,0.f, object.Box.width, object.Box.height); // object.Box is just a sf::Rect<int>
        sf::FloatRect globalBounds( temp.transformRect( localBounds ) );
        bb = { globalBounds.left, globalBounds.top, globalBounds.width, globalBounds.height };
 

now if I just use:
sf::Transformable temp;
temp.setPosition(object.getPosition().x, object.getPosition().y);
temp.setOrigin(object.getOrigin());
temp.setRotation(object.getRotation());
temp.setScale(object.getScale());
 

then compute the local bounds and global bounds it works fine, so I'm pretty sure I'm just not using the combine method the right way, is not a big deal, since I got it working with the second method, I just want to know how to use the sf::Transform::combine method the right way, thanks.

2
Graphics / Rendering slows down FPS
« on: September 26, 2013, 05:17:37 am »
I am so frustrated trying to figure out why every time I render a "tile map" it slows down game play so much, I used a simple nested for loop to draw tiles like so:
Quote
for(int y = 0; y < mapHeight; y++)
for(int x = 0; y < mapWidth; x++)
{
    v.push_back(tile);
// same as v[y]
  • ; you get the point...

}

I thought this was the problem so I copied and pasted the code to for tile map from this LINK: http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php 

and yet again same thing happens, I have a simple question:
is it supposed to slow down the overall game play the more you draw? it makes no sense to me because if I draw a map lets say 40x40 it slows down a little, then if I draw 80x80 it pretty much slows down twice as much and so on so forth...

Is it maybe a bug with my entity update and/or rendering logic? I don't think it is, is simple update/rendering logic.

If you guys want to see some code, I would happily post it, I don't think it is needed, this happens regardless of how I approach it...

3
Network / Sfml packet questions
« on: May 26, 2013, 07:51:32 am »
Hello everyone, I hope this hasn't been asked before I have searched for a while now and could not find the answer to this...

The Sfml::Packet class is pretty simple and I'm trying to do something like what the class does, where I am having trouble is copying unsigned long or long long etc, I was using stf::copy but it was not working properly... I then used memcpy and it works but then I'm having trouble with the position on vector... take a look at this:

This is the Packet& operator >> (const unsigned long & data)
Quote
std::copy(&data, &data+ sizeof(data), std::back_inserter(buffer));

This is the Packet& operator >> (unsigned & long data)
Quote
std::copy(buffer[0] + pos, &buffer[0] + pos + sizeof(data), &data);
        pos += sizeof(dataSize);

this work for small numbers but if I use bigger numbers it will spit random numbers....

If Laurent or anyone that has had some experience with could help me with this, that would be awesome.

the memcpy version works like this
Quote
memcpy(&buffer[0], &data, sizeof(data));

AND:

memcpy(&data, &buffer[0], sizeof(data));

But the problem is when I use the operator it is always getting buffer[0] obviously and I am stuck on how to move the pos variable accordingly, it is really late an I have been at it for a while so I know is probably simple but my brain is blocking common sense right now...

4
SFML projects / Map00(tile editor) - binary + source
« on: May 18, 2012, 06:58:40 am »
Hello guys, I am releasing my "tile map editor", it is very simple right now but it gets the job done ;).

Features:
  • Load .nyb configuration files
  • Loads textures only once.
  • scrolling camera with Left/Right  Up/down buttons
  • right mouse button deletes tiles
  • left mouse button creates current selected tile

Notes:
  • the .nyb file contains the map name, map Width/Height, the tile size, map file and map texture. the files MUST be in the same directory for it to properly load them.
  • It uses a texture cache class to load textures, this prevents re-loading the same image more than once
  • My current camera class is much better than the one in this project and has the ability to lock on to targets, this can be easily implemented here.

DOWNLOAD: http://www.mediafire.com/?q1zwta1vv1q38q1

How to use:

1. You can either generate a map by creating a new mapEdit object like this:
Code: [Select]
Ccamera mapCam(640, 480);
mapEdit oMap("My map", 40, 40, 32, "tileSet.png",  mapCam);
Or like this :

Code: [Select]
Ccamera mapCam(640, 480);
mapEdit oMap(mapCam);

oMap.generate("My map", 40, 40, 32, "tileSet.png",  mapCam);

First is map name, then map width, map height, tilesize, tileset texture (PATH) and camera object,
after that you can edit your newly created map and save it.

To load a map is rather  easy this is how :
Code: [Select]
Ccamera mapCam(640, 480);
CmapEdit oMap(mapCam);
oMap.loadConfig("map00/map00.nyb");

and the map will be loaded using the loadConfig(std::string& _mapConfig); function, you can also load it at anytime using this function instead.

2. There are a couple of stuff I need to fix specially some of the mapEdit functions, I will fix them and update you guys.

Controls:
Quote
1. Scrolling : Left/Right, Up/Down   ( scrolls through the map ).
2. Placing tiles: mouse left click.
3. Deleting tiles: right mouse click.
4. changing tiles: A/S - A to move forward on the tile sheet and S to move backwards.
5. Save map: just press the X button on your keyboard.

Things to come:
  • Map clearing: a single press of a button and clear out the whole map
  • map generation/loading input: I'm going to implement a better way to load and create map files by input rather then having to manually edit the code ;)

Please leave comments/criticism/feedback if you want.

You can use this however you please, but don't claim as your own  :-\, I encourage to expand on it too and share!!

Media:




DOWNLOAD: http://www.mediafire.com/?q1zwta1vv1q38q1

5
SFML projects / _Prot0 - 2d Engine
« on: May 16, 2012, 09:50:46 pm »
Hello there every one,

I just wanted to share this with you, it is an engine I am working on right now, well actually I had worked on a very similar one before with SDL, but it was not nearly as good as this one is right now. I had to code everything from scratch after trying to switch from SDL to SFML and after getting a lot headaches I finally decided to just do it from scratch and I'm glad I did.

This is a simple 2d engine with basic collision detections ( bounding box, but I added my own things to make it really precise), tile maps, scrolling camera etc. Right now I'm in the process of creating enemy classes etc, I also use my own tile map editor, I will show a video of that soon, and I will be releasing the map editor + source code soon.

By the way, great job on such an awesome library Laurent.

Video 1:


Video 2:


Video3:

Pages: [1]
anything