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 - Mossar

Pages: [1]
1
Graphics / Collision of rotated Rectangle
« on: October 10, 2013, 10:47:00 am »
In my game I've got collision mechanism, but it works fine only on rectangles which are not rotated. I decided to add boxes which are rotated, but, of course, my application detect collision between character and bounding box which is not rotated and is not returning real bounds of a rectangle.

I found that article about doing it: http://www.gamedev.net/page/resources/_/technical/game-programming/2d-rotated-rectangle-collision-r2604. I have not read it yet, but as I see you have to get local (not global) x-axis and y-axis of rectangle and create your own system of collision without using, in SFML, getGlobalBounds().

I've got idea how to do it that way, but I'm curious if it's possible to detect collision between rotated object with SFML functions? Or maybe you can advise me how to implement that in a quite simple way.

2
Graphics / Re: Solution for big size of array
« on: September 12, 2013, 05:53:46 pm »
Thank you guys.

Today I've changed it to VertexArray and I did it with an algorithm which is very similar to that written by FRex. It differs, but this is connected with the same idea.

And I decided to create my own class Primitive, Figure is a base class, Primitive and Image inherits from Figure. With that and with virtual functions and polymorphism I can check collision on primitives and sprites with the same algorithm using Figure class. I dont know, maybe that approach will give me performance problems later, but now there are no problems with it :)

Later I will optimize it with approximation to collect primitives into bigger primitives (maybe TriangleStrip or bigger sf::Quads). Now I have to concentrate on gameplay things and I have to draw a lot.

Thanks again :)

3
Graphics / Re: Solution for big size of array
« on: September 12, 2013, 01:02:42 am »
I'm assuming you're only drawing circles that have 3 points each and same radius, if not the instruction would need adjusting:
1. put points as float pairs into std::vector or something(maybe add radius or color if you need to customize that)
2. make static array of vertices so you won't have to allocate one each frame
3. each frame start setting vertices in that static array to proper value so that every three are a circle around pair in that list of pairs from point 1(can also discard using points outside the screen+radius bounding rectangle here)
4. draw that vertex as sf::Triangles vertex array when it's full or when you run out of float pairs
5. repeat until done with all float pairs


I am not sure if I understand it well but if I understand it well it will be good idea in my opinion. I'm drawing only RectangleShapes which are 3px by 3px. A lot of them. And you propose me btter idea of drawing it with a VertexArray arround the points from another array containing coordinates of points. Using sf::Triangles.

And I can optimize it (using approximation) with sf::TrianglesStrip? Is it good approach?

4
Graphics / Re: Solution for big size of array
« on: September 12, 2013, 12:42:02 am »
Thank you for your reply ;)

First, you should reduce the number of points. The geometric objects in your image are almost straight, thus they don't need many points for the approximation. When you draw a platform, define a minimum distance to the last point drawn before you add a new one.

I thought about it, this is a little harder, but I won't learn anything if I don't do more difficult things :) I still don't know if I want to be a programmer or graphic designer but I really want to be better programmer so I have to try it. But there is one problem for me. We can imagine that there is player who draw something very weird and lines are very crooked. In that case approximation will help of course but not very much. I will implement that idea, but I'm not sure if it solves a problem in 100%. Will using approximation + ,for example, VertexArray give me enough effect?

Quote
On SFML side, draw lines between the points, instead of points themselves. You could have a look at custom sf::ConcaveShape. Or even sf::VertexArray, but I would keep things simple until you really need the flexibility or performance.

I must read something about that ConcaveShape because I don't know what is it. This is my second game ever and second game in SFML and as I can see I didn't know every element of this great library.

Quote
And you should definitely not use new and delete.
Me and my friends from University, we always say that pointers are not nice :D Thank you for confirming :D Seriously, nice pdf, thanks :)

5
Graphics / Solution for big size of array
« on: September 12, 2013, 12:03:36 am »
Firsteval look at the screenshots.

http://oi39.tinypic.com/15mzev5.jpg
http://oi44.tinypic.com/23j4s9c.jpg

Ok so this is normal platform game but additionally you can draw something on a screen with your mouse and you can use it as a landing, shield, barrier, etc. On the screens you can see that you can jump on it.

The problem is algorithm which do that lines. Every line contains hundred of points which are done with sf::Shape:
Image[BarrierCounter] = new Shape(sf::Color::Black, 3, 3);
 
Of course Shape is my own Class which has sf::Shape in it.

As I said every line contains on average two hundred of 3px:3px points (of course you can do a line or circle or what you want with thousand points for example but I want to describe a problem). It means that if I have array with 2000 elements I can draw ~10 lines. Of course I want to make that amount bigger. And now there is a problem because I can't do array with bigger amount because there is a problem with graphic card memory, I think. I read that this is connected with many calls of draw function.

So what should I do to avoid it, to make possible creating a lot of lines. VertexArray? Or what?

6
General / Re: Effect of drawing with pencil
« on: August 10, 2013, 01:59:17 pm »
Oo, very nice, thank you. But now I won't use it, this line look quite good after "filling" algorithm and I want to improve other things in my game. This is something what I will do if I have almost whole game designed.

Now I have another problem. When I draw a lot of lines, there are thousands of images(points) on a screen. On my computer there is exception after drawing all the points, when I increase array to 2000 elements. I've heard that this is connected with graphic card and I should use VertexArray using one texture. What do you think? Should I consider it?

But I can't imagine how to prepare one texture divided for 4x4 tiles doing smooth line? If it was only 1368:768 black texture and I "activated" 4x4 points with my mouse it would be very sharp and it wouldn't look like a pencil.

7
General / Re: Effect of drawing with pencil
« on: August 09, 2013, 03:45:14 pm »
Hah it's funny. When I had interpolation on university everybody thought it is useless in programming. Probably it is the problem of professor, who couldn't explain where we can use it.

8
General / Re: Effect of drawing with pencil
« on: August 09, 2013, 11:10:26 am »
That algorithm look nice and it doesn't depend on computer's speed. I will try it because it is probably the most proper way.

But this algorithm has got one problem (I mean algorithm which do a straight line between points). User will try to do a line which is not straight, for example something similar to y=x^2. If he did it fast, app would catch only few points and he wouldn't get y=x^2 but curve with sharp edges.

But it doesn't change that this idea is very nice ;) Maybe I would try to smooth that edges later.

9
General / Re: Effect of drawing with pencil
« on: August 09, 2013, 12:42:14 am »
Hmm, ok I will try to change my algorithm.

So instead of:
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
I should try:
if (Event.type == sf::Event::MouseMoved)
?

Of course I know that I MUST use the first "if", but only once at the beginning of drawing. After pressing I should use MouseMoved to catch every pixel. I hope it would work ;)

Ok I will try tomorrow, it's 1AM in my country ;) Thank you for help.

10
General / Effect of drawing with pencil
« on: August 09, 2013, 12:19:26 am »
My goal is a 2D platform game with additional possibility to draw things on a screen (like with a pencil or a brush in Photoshop). I did everything what is connected with platform game mechanic, I did effect of drawing on a game screen.

When I move pressed mouse with medium or slow speed everything is OK and there is quite smooth line. But there is quite difficult problem when I want to draw something faster. If I try to draw a line faster, application will "catch" only few points of a line. Example:


In my opinion there are 3 possible ways to repair it:
  • filling free spaces between dots with ultra-advanced algorithm :D
  • slowing down mouse
  • improving application speed

ad1. This is the way I will probably try to do it , but I think it will be quite difficult to invent nice way to make it look smooth and natural. If you have any idea, please help me :) Maybe use of y=ax+b and filling every point between these 2 following points?

ad2. This is the way I TRIED to do it. I was setting Mouse Position with setPosition just near last mouse position. It was working but: slowing down mouse is not the best way in my opinion to repair it. I was using y=ax+b to calculate the most accurate position, but of course it wasn't accurate because of sf::Vector2i. It was impossible to make that line connected in 100% with a mouse movement.

ad3. I'm not sure if it was possible. It depends on speed of user's computer so I think it is not the best way.

This is not a problem of bad algorithm of drawing. I was "cout"-ing mouse position in an application with almost nothing and it's just to fast for application to catch every single (x,y) position.

Ok. So I wanted to ask if you have any idea to do it.

11
Audio / Re: Issue 30
« on: May 03, 2013, 01:07:40 am »
Okay. Can I ask you for something? Are you working on solving that problem? I don't know.. fixing it in next version or something like that?

So I understand that the only option to give my application music is to include other directory?

12
Audio / Issue 30
« on: May 02, 2013, 12:13:52 am »
I've read a lot of topics about that problem, about crash after closing the application. And I don't know what is the solution, what should I do to fix it?

Should I add any .dll file? Change something in SFML? Can somebody help me with it?

13
Graphics / Proper method of doing animation
« on: March 04, 2013, 12:44:30 pm »
I'm new in using SFML and I've just done algorithm for movement of my character in my game. Everything works on my computer but I'm not sure is it a good way of doing animation with SFML. It looks like that

                sf::Time time= timer.getElapsedTime();
       
                if(time < t1) {  s = 0; sprajt.setTexture(leftleg); }
                if (time > t1 && time < t2){    if (s == 0){  sprajt.move(30,0); s = 1; } sprajt.setTexture(stand); }
                if (time > t2 && time < t3) {   s = 0; sprajt.setTexture(rightleg); }
                if (time > t3 && time < t4){    if ( s== 0){  sprajt.move(30,0); s = 1; } sprajt.setTexture(stand);  }
                if (time > t4) timer.restart();
        }
 

Firsteval it is changing texture to "left leg texture", after t1 it is moved by 30 pixels and texture is changed to "standing texture", etc.

I'm curious is there (in SFML) better way of doing it? For example with framerate?

14
Window / Re: Fullscreen without resizing
« on: February 23, 2013, 02:44:24 pm »
Haha, thank your very much :)

It's funny when you create difficult methods of moving character in a game or collisions but you can't create the easiest ideas like that. I'm ashamed :D

15
Window / Fullscreen without resizing
« on: February 23, 2013, 01:44:13 pm »
I'm just curious about doing something like that:

I've got game project and it's 800px:600px.
I wanted to make it more "professional" and make this game fullscreened.
Normal fullscreening resize my project and it fits to my current system resolution.

And there is a question: is it possible to fullscreen a window without resizing? Just 800:600 game in the middle of the screen surrounded with black colour? Of course I can draw my background texture with black colour around background but I'm just curious is there option to do what I want.

Pages: [1]