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

Pages: [1]
1
So I'm making those libraries that can animate changes (like position change, scale, origin and rotation), execute functions after timeout and in intervals and making event listener and onclick functions (which isn't coming up very fast since there are many different events and when you rotate and do other stuff to sprite it is hard to determine is it clicked on or not).

I putted a test exe file in attachments (dosen't include the 3 dll files needed to run it, so you will have to add that).
It has 1 second timeout till beginning and I seted an interval to repeat the animation every 9 seconds, because that is how long it lasts.

So try out my test file and if anyone has any idea what else I could make please tell.

[attachment deleted by admin]

2
General / Events & Animations
« on: May 01, 2013, 12:08:28 am »
So I made a little library which beside other functions has setInterval and setTimeout functions.
They are part of my class which I call zSFMLe and it has a class Loops of which I made a vector.
Those 2 functions takes a function pointer, which takes a void pointer, and a void pointer to be passed to that function and time in milliseconds.
How I made it is that you make a zSFMLe object and use its functions setInterval and setTimeout to add things to the vector. It also has a timing function which I call every time before drawing, it checks should any of the functions be called.

Now the problem is that I have to make a new class that will contain all the data that I have to pass to that function, I have to use void pointer to pass that object to the function and then make variables in which I will store the values which I stored in the object.
Is there an easier, simpler way to pass data to a function?


That library also has onclick and addEventListener functions, although they aren't finished, so they do only the most basic things.
I also have a animation library that animates chenge of Position, Rotation, Scale and Origin, but only linearly, I'm planing to add nonlinear (how ever that is called) animation soon.

I putted a test exe file in attachments (dosen't include the 3 dll files needed to run it, so you will have to add that).
It has 1 second timeout till begining and I seted an interval to repear the animation every 9 seconds, because that is how long it lasts.



[attachment deleted by admin]

3
General / Calculating position
« on: March 25, 2013, 11:56:16 pm »
Ok, so now I have reversed problem (reverse of my other question).
I have the angle and the vectors lenght and I need x and y (if the vector starts at the coordinates 0,0).
I have tryed something, but it didn't gived the correct results and when I though about it I realized why and I'm just to tired to think about it any more.
So if anyone has any ideas please post.

Not important: I need this because I have a rectangle (sprite) in the middle of the screen, with origin in it's middle and it is rotated by the player. Now I have to get the x,y of the sprite's corners (all 4 of them) to calculate if he can no more rotate in that way or go forwards/backwords.

4
Graphics / Squere Fullscreen
« on: March 24, 2013, 12:20:43 pm »
How do I make a game fullscreen, but use only the center part of the screen, so that the space I'm using has same hight and width?

5
General / Get picture from swf file
« on: March 21, 2013, 11:20:31 am »
So I'm making a game and I needed pictures for my tank and for enemies, so I found this game on the internet which has exactly the stuff I need. So I downloaded it and searched for something toget those images out of that swf file, but couldn't find anything that would work.
Dose anyone know how to get images from a game in swf format?

6
General / Calculating direction
« on: March 19, 2013, 10:02:36 pm »
On the middle of the screen I have a sprite whose origin is set near the bottom, so in the start it "points" up.
Now when I get cursor coordinates how do I calculate what to set for rotation so that it "points" to the cursor position?

7
Graphics / geting pixel
« on: March 19, 2013, 03:45:17 pm »
So, I have this map image. Some of it is dark some bright. And the players can't go onto the dark parts.
The player is a rectangle which is always in the center of the map, but it rotates.
Any ideas how to check is player on a dark part even a pixel?

8
Graphics / setPosition to negative value
« on: March 19, 2013, 02:54:47 pm »
I have a circleshape and I set it's position like this
curView.setTextureRect(IntRect(cursorX - cursorV, cursorY - cursorV, cursorV*2, cursorV*2));
cursorV is the the radius of curView

But if cursorX - cursorV or cursorY - cursorV results in negative then the circle dosen't display at all. (so I had to limit the result to zero)
How do I go around that?

9
Graphics / Dynamic texture
« on: March 18, 2013, 09:50:18 pm »
I have an image, the game map.
I have to use different part of the map as the player moves. And my idea is to use texture that would contain different part of the image.
But, since I'm new to sfml, I don't know how to set the texture to a certain part of the image and how to change the viewed part later on.
So, any ideas?
I know I can just set TextureRect for each element, but I don't want that.

10
Graphics / <Tank Wars> need help with multiple grafic things
« on: March 17, 2013, 05:03:30 pm »
So I'm working on this tank game and since I'm new to sfml I have several questions.

My first question is is it posible to have a background image and show the part that is undernith a circle and leave everything else black? Because I have those CircleShapes and for now I am calculating what part of the map is sapoust to be undernith the circle and I just don't like it and will like it even less when I add some more circles.

Second question, when you compile and run that code you will notice that cursors circle goes all the way on the right and bottom, but only taches the top and left edge. That is because I had to block it from going closer, because if it goes closer it simply dosen't display from some reason. Dose anyoe have any idea how to fix that?

And third, is it posible to set circle so that the part in the center is brightest and as you go furter from the center it becomes darker? Or will I need to use multiple circles and their outlines?


My code till now.
Map.jpg

#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
    const unsigned tankV = 150, cursorV = 100;
    const unsigned speed = 10;
   
    VideoMode vMode(1024, 768, 32);
    RenderWindow window(vMode, "Tank Wars", Style::Fullscreen);
    window.setMouseCursorVisible(false);
    window.setFramerateLimit(60);
   
    Texture Map;
    if(!Map.loadFromFile("Map.jpg")) return 1;
    Map.setSmooth(true);
   
    const unsigned mapW = Map.getSize().x, mapH = Map.getSize().y;
    unsigned positionX = mapW/2, positionY = mapH/2, cursorX = positionX-200, cursorY = positionY-200;
   
    CircleShape tankView(tankV);
    tankView.setTexture(&Map);
    tankView.setPosition(vMode.width/2-tankV, vMode.height/2-tankV);
    tankView.setFillColor(Color(255,255,255,200));
   
    CircleShape curView(cursorV);
    curView.setTexture(&Map);
    curView.setFillColor(Color(255,255,255,200));
   
    while(window.isOpen())
    {
        Event event;
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case Event::MouseMoved:
                    if(event.mouseMove.x > cursorV)
                        cursorX = event.mouseMove.x;
                    else cursorX = cursorV;
                    if(event.mouseMove.y > cursorV)
                        cursorY = event.mouseMove.y;
                    else cursorY = cursorV;
                    break;
                case Event::Closed:
                    window.close();
                    break;
                case Event::KeyPressed:
                    switch(event.key.code)
                    {
                        case Keyboard::Up:
                        case Keyboard::W:
                            if (positionY > 100)
                                positionY -= speed;
                            break;
                        case Keyboard::Down:
                        case Keyboard::S:
                            if (positionY < mapH-100)
                                positionY += speed;
                            break;
                        case Keyboard::Left:
                        case Keyboard::A:
                            if (positionX > 100)
                                positionX -= speed;
                            break;
                        case Keyboard::Right:
                        case Keyboard::D:
                            if (positionX < mapW-100)
                                positionX += speed;
                            break;
                        case Keyboard::Escape:
                            window.close();
                            break;
                        default: break;
                    }
                    break;
                default:
                    break;
            }
        }
       
        curView.setTextureRect(IntRect(positionX - vMode.width/2 + cursorX - cursorV,
                                       positionY - vMode.height/2 + cursorY - cursorV,
                                       cursorV*2, cursorV*2));
        curView.setPosition(cursorX-cursorV, cursorY-cursorV);
       
        tankView.setTextureRect(IntRect(positionX - tankV, positionY - tankV,
                                        tankV*2, tankV*2));
       
        window.clear(Color(0,0,0));
        window.draw(curView);
        window.draw(tankView);
        window.display();
    }
   
    return 0;
}

11
SFML projects / Tank Wars
« on: March 17, 2013, 11:25:55 am »
So, I have this image (the map) loaded, then puted into a texture.
Image map;
if(!map.loadFromFile("Map.jpg")) return 1;
const unsigned mapW = map.getSize().x, mapH = map.getSize().y;
Texture Map;
Map.loadFromImage(map, IntRect(0,0,mapW,mapH));

Then I added that texture to CircleShapes, one is in the middle and the other is where the mouse is.
CircleShape tankView(tankV);
tankView.setTexture(&Map);
tankView.setPosition(vMode.width/2-tankV, vMode.height/2-tankV);
CircleShape curView(cursorV);
curView.setTexture(&Map);

In the while loop I get XY of the mouse and see if the player moved (w,a,s,d) and acording to that I setPosition of the cursor's CircleShape and setTextureRect (part of the texture) that should be displayed in each of the CircleShapes.

All that works well, but I have a problem, the picture of the map is to small and when I tried to resise the image to a apropriete size I found out that there is a limit for the texture's picture size and it is way smaller that what I need. So I tried to put smaller width/height in setTextureRect, but then cursor's and centered CircleShape didn't overlap correctly and the cursors background looked like it moves when mouse moves. So, how do I zoom in?

My first idea was to have the background, which would be hidden and when a CircleShape is over it it gets displayed, what would be much easyer to work with, but I have no idea how to do that or is it even posible?

Pages: [1]
anything