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

Pages: [1]
1
C / Re: sfRectangleShape doesn't render anything in an array.
« on: November 16, 2013, 12:44:57 am »
Thanks Jebbs that worked. I thought I did put size of the rectangle, but I didn't.

2
C / sfRectangleShape doesn't render anything in an array.
« on: November 15, 2013, 11:33:06 pm »
So I'm trying to render RectangleShapes in an array. However, it won't draw at all. I don't know what I'm doing wrong, I had a similar problem with sprites having to bind the texture before rendering.

So I have a array of sfRectangleShape*  and I render it to the screen, but I get just the player being render.

#include "serkill.h"

#include <SFML\Graphics.h>
#include <stdio.h>

enum terrain_num terrain[DUN_WIDTH][DUN_WIDTH];
sfRectangleShape* terrain_image[DUN_WIDTH][DUN_HEIGHT];

void init_map()
{
        sfVector2f position;
        int x;
        int y;
        sfVector2f scale;
        sfColor color;
        scale.x = 32;
        scale.y = 32;

        for(x=0; x<DUN_WIDTH; x++)
        {
                for(y=0; y<DUN_HEIGHT; y++)
                {
                        if(x==10 && y==0)
                        {
                                terrain[x][y] = WALL;
                        }
                        else
                        {
                                terrain[x][y] = FLOOR;
                        }
                }
        }

        for(x=0; x<DUN_WIDTH; x++)
        {
                for(y=0; y<DUN_HEIGHT; y++)
                {
                        terrain_image[x][y] = sfRectangleShape_create();
                }
        }

        for(x=0; x<DUN_WIDTH; x++)
        {
                for(y=0; y<DUN_HEIGHT; y++)
                {
                        position.x = x*32;
                        position.y = y*32;
                        sfRectangleShape_setPosition(terrain_image[x][y], position);
                        if(terrain[x][y] == WALL)
                        {
                                color = sfCyan;
                                sfRectangleShape_setFillColor(terrain_image[x][y],color);
                               
                        }
                        else
                        {
                                color = sfWhite;
                                sfRectangleShape_setFillColor(terrain_image[x][y],color);
                        }

                        sfRectangleShape_setScale(terrain_image[x][y], scale);
                }
        }
}

void terrain_render()
{
        int x=0;
        int y=0;
        sfColor color = sfWhite;

        for(x=0; x<DUN_WIDTH; x++)
        {
                for(y=0; y<DUN_HEIGHT; y++)
                {
                        sfRectangleShape_setFillColor(terrain_image[x][y],color);
                        window_display_rectangle(terrain_image[x][y]);
                        printf("%f \n", sfRectangleShape_getPosition(terrain_image[x][y]).x);
                }
        }
}

void window_display_rectangle(sfRectangleShape* shape)
{
        sfRenderWindow_drawRectangleShape(window, shape, NULL);
}

Main loop

void main_loop()
{
        enum game_cmd cmd;
        int i;
        sfEvent event;

        while(window_isOpen())
        {
                while(poll_window_event(&event))
                {
                        cmd = get_command(&event);

                        do_command(cmd);
                }

                window_clear();

                terrain_render();

                render_player();

                window_display();
        }

}

3
Network / Re: Entering IP address problem?
« on: August 04, 2013, 12:53:38 pm »
That works. Thank you.

4
Network / Entering IP address problem?
« on: August 04, 2013, 01:20:11 am »
I don't know. If I uncomment everything is fine. I tried getlocaladdress, localhost. Tried typing it different ways like without . Tried different methods.

Yet nothing seems to work.

A friend ran this code on his computer that uses linux. He said it worked fine and connected. It might be firewall, but I disabled it and still get the same problem.  I'm doing this over wifi so that might be blocking it. However, that wouldn't explain why it works when I uncomment it. 

#include <SFML\Network.hpp>
#include <iostream>
#include <string>
#include <map>
#include <conio.h>

int main()
{
        std::string text = "Connected to: ";
        std::string sIP;
        unsigned short serverport = 2000;

        sf::TcpSocket socket;

        std::cout<<"Enter server ip: ";
        std::getline(std::cin, sIP);

        sf::IpAddress ip(sIP);

        socket.connect(sIP, serverport);

        //sf::IpAddress ip = sf::IpAddress::getLocalAddress();
        //socket.connect(ip, serverport);

        system("pause");

        return 0;
}
 

Pages: [1]
anything