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

Pages: [1] 2 3
1
##### Graphics / How incorporate more tiles instead of just one?
« on: June 29, 2014, 09:37:10 am »
How would I add more than one tile to this vertex map? Haven't been able to find a solution, and my ideas that I have tried are very slim on working.

I want to be able to use more than on tile (like look at an array and replace the numbers with a tile???)

Any clues/help to get me started?
{
public:
{
m_mapdata.MapX = 100;
m_mapdata.MapY = 100;
m_mapdata.TextureName = "0.gif";
}
virtual void AppendTile(int gx, int gy, sf::VertexArray& garr)
{
sf::Vertex ver;
ver.position = sf::Vector2f(gx*16.f, gy*16.f);
ver.texCoords = sf::Vector2f(0.f, 0.f);
garr.append(ver);

ver.position = sf::Vector2f(gx*16.f + 16.f, gy*16.f);
ver.texCoords = sf::Vector2f(16.f, 0.f);
garr.append(ver);

ver.position = sf::Vector2f(gx*16.f + 16.f, gy*16.f + 16.f);
ver.texCoords = sf::Vector2f(16.f, 16.f);
garr.append(ver);

ver.position = sf::Vector2f(gx*16.f, gy*16.f + 16.f);
ver.texCoords = sf::Vector2f(0.f, 16.f);
garr.append(ver);
}
};

2
##### General / Re: Finding out what Tile your on from the VerterArray TileMap Example
« on: June 14, 2014, 02:58:38 pm »
but the tile number your on
What does "you're on" mean? Who is "you"? The mouse cursor? A game object? Please express yourself clearly.

If you have the coordinates, you can divide them by the tile size to learn the tile index. If the vertex array doesn't start at (0,0), you have to offset accordingly.

Sorry, the "you" is the gameobject, I haven't gotten the coordinates as of yet.

3
##### General / Re: Finding out what Tile your on from the VerterArray TileMap Example
« on: June 14, 2014, 02:50:16 pm »
Quote
showing what tile your on
What does that mean? Do you want to get the tile coordinates? Or something else?

Coordinates would be good, but the tile number your on; 1, 12, 4 etc. Where the level is loaded, that number array, finding out which number your sitting on.

4
##### General / Finding out what Tile your on from the VerterArray TileMap Example
« on: June 14, 2014, 02:37:39 pm »
How would you go about showing what tile your on with a VertexArray Tilemap that is based mostly on the example?

Really simple answer, but I'm just lost at where to start with it.

Cheers

http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php

5
##### Graphics / Re: Changing Sprite Texture on key press not working?
« on: June 13, 2014, 01:45:21 pm »
Solved!

Had a line that was continuously replacing the texture back to the normal. Was in a function being looped and moved that out and works well.

Move this out of PlayerSetup and into Init()
p_sprite.setTexture(tp_sprite);//Set Texture

6
##### Graphics / Re: Changing Sprite Texture on key press not working?
« on: June 13, 2014, 10:21:10 am »
No, I don't do everything on the one line, the issue I have is that when I hit another key, it doesn't change the sprites texture.  This is the part of the script that controls the player and movement

#include <SFML/Graphics.hpp>
#include <iostream>
#include "Lester.h"

sf::Texture tp_sprite_l, tp_sprite_r, tp_sprite_d, tp_sprite;
sf::Sprite p_sprite, p_sprite_l, p_sprite_r, p_sprite_d;

void Lester::PlayerSetup()
{

p_sprite.setTexture(tp_sprite);//Set Texture

window->draw(p_sprite);
}
void Lester::KeyInput()
{

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape) || sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Q)){ window->close(); }
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))  p_sprite.move(-4, 0); m_view->move(-4, 0); std::cout << "LEFT" << std::endl;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D)){ p_sprite.move(4, 0); m_view->move(4, 0); std::cout << "RIGHT" << std::endl; }
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S)){ p_sprite.move(0, 4); m_view->move(0, 4); std::cout << "DOWN" << std::endl; }
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)){ p_sprite.move(0, -4); m_view->move(0, -4); std::cout << "UP" << std::endl; }
}
void Lester::Screen()
{

window->setView(*m_view);//Set Game View
Map();//Call Map
window->draw(m_map);
PlayerSetup();
}
void Lester::GameScreen()
{
window->setView(*m_view);
window->clear();
Screen();
}
void Lester::GameLoop()
{
window = new sf::RenderWindow(sf::VideoMode(960, 550, 32), "Lester V:0.1");
m_view = new sf::View(sf::FloatRect(200, 200, 300, 200));//View Port
m_view->zoom(0.7f);//Set Zoom

window->setFramerateLimit(60);//Set FrameRate
window->setVerticalSyncEnabled(true);

p_sprite.setPosition(300, 250);

while (window->isOpen())
{

sf::Event event;
while (window->pollEvent(event))
{
if (event.type == sf::Event::Closed)
window->close();
}

running = true;

while (splash_set == false){window->display();splash_set = true;}
if (splash_set == true){ window->clear(); KeyInput();PlayerSetup(); GameScreen(); window->display(); }
}
}
void Lester::Init(){ GameLoop(); }

7
##### Graphics / [RESOLVED]Changing Sprite Texture on key press not working?
« on: June 13, 2014, 09:57:04 am »
Hey,

I've been stuck on this for a few hours now, and I'm lost. I have a if statement that lets me move my sprite, but for it to control the player, I need it to change the sprite texture according to what key is pressed,

I have this for my if statement to change the texture :

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)){ p_sprite.move(4,0); p_sprite.setTexture(tp_left);}

I have the textures setup in the header file as

Im drawing the sprite, the player loads fine and I can move correctly, just the changing of textures of the player on certain keys is confusing me.

Thanks

8
##### Graphics / Re: No Errors, but Sprite wont draw?
« on: May 15, 2014, 01:01:48 pm »
You should not be drawing the sprite in your player's constructor/init method.  draw() calls should only happen in between the clear() and display() calls of your main loop.  If PlayerSetup() is being called every frame, then only draw() should be in there.

Quote
This is being called after a statement returns true
If you feel the need to describe more of your code, that implies you haven't shown us enough of the code to begin with.  If you need more help be sure to post a *complete* and minimal example.

This the entire cpp file for drawing onto screen. http://pastebin.com/8j59jtvF

I've added the draw() and display() calls in the main loop, and set it so its just draw() in PlayerSetup(), but it still isn't showing?

9
##### Graphics / No Errors, but Sprite wont draw?
« on: May 15, 2014, 02:36:42 am »
Hi, I've been having troubles drawing my sprite, in my Player class where I'm loading the images, I get no errors when loading the images for the texture, but when I goto run the application, the sprite isn't showing, I have other objects being drawn as well, I have the player being drawn last after everything else, but still down do anything?

Any Ideas?

Drawing the Characters Sprite (This is being called after a statement returns true)
void Lester::PlayerSetup()
{
Player player = *new Player();
sf::Sprite p_sprite(player.p_sprite);
p_sprite.setPosition(200, 200);
p_sprite.setTexture(player.tp_sprite);

window->draw(p_sprite);
}

void Player::texture()
{

if (!tp_sprite.loadFromFile("data/assets/player/up_char.png")){ std::cout << "Unable to load Player Sprites! Please report this Error!"; }
else{ std::cout << "Player Sprite was Loaded Correctly"; }
p_sprite.setTexture(tp_sprite);
}

Cheers.

10
##### Network / Re: Load Sprite texture from Website
« on: April 20, 2014, 02:20:50 am »
Don't you want to try by yourself first?

It's really easy, and the doc + tutorials are more than enough to guide you.

Can't find any good tutorials with a search :s

11
##### Network / Re: Load Sprite texture from Website
« on: April 18, 2014, 08:54:07 am »
Two simple options:

1. Get the image from the website to a memory buffer, then use sf::Texture::loadFromMemory.
2. Save the image from the website to a file, then use sf::Texture::loadFromFile.

Can you justify how one could do this?

12
##### Network / Load Sprite texture from Website
« on: April 18, 2014, 08:39:11 am »
Hi,

What would be the easiest way to convert what I have here, to display my sprites textures instead of using .loadFromFile?

sf::Http::Request request("image.png", sf::Http::Request::Post);

sf::Http http("http://mysite.com/");
sf::Http::Response response = http.sendRequest(request);

// check the status
if (response.getStatus() == sf::Http::Response::Ok)
{
// check the contents of the response
std::cout << response.getBody() << std::endl;
}
else
{
std::cout << "request failed" << std::endl;
}

This just shows the image.png contents in the console, I want to be able to draw a sprite from fetching the image from the website, is it possible to do this?

Cheers.

13
##### Window / Re: Unresolved External on changing Window Size
« on: April 14, 2014, 01:55:06 am »
The code seems fine to me. That error is definitely a linker error. See here:
Linker Tools Error LNK2019

Maybe you are using Visual Studio 2013 and downloaded the libraries from the website? Then you would need to compile SFML yourself.

compiled SFML for my VS Studio 2013, added the .dll files to the project and it still does it.

14
##### Window / Re: Unresolved External on changing Window Size
« on: April 14, 2014, 12:37:56 am »
That's a linker error, so you're not linking against the SFML libs correctly.  Reread the SFML build tutorial very carefully and double check all of the IDE settings it mentions.

I've re-read the build tutorial, the IDE settings are the exact same as everything else, before I added that function into my project, it was all working fine.

o.O

15
##### Window / [Solved] Unresolved External on changing Window Size
« on: April 13, 2014, 01:54:47 pm »
Hello, I have just ran into an error when trying to resize my screen via a function,

error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::setSize(class sf::Vector2<unsigned int> const &)" (__imp_?setSize@Window@sf@@QAEXABV?\$Vector2@I@2@@Z) referenced in function "public: void __thiscall Lester::GameScreen(void)" (?GameScreen@Lester@@QAEXXZ)

This is the function resizing:

void Lester::GameScreen()
{
window.clear();
window.setTitle("Lester V0.1");
window.setSize(sf::Vector2u(960, 550));
Screen();
}

Any ideas?

Cheers

Pages: [1] 2 3
anything