I'm thinking of starting Argument Archive® ...it will scan new posts in WAYWO and if it detects an argument we've had before it will link to the previous outcome.
I think it will be better for everyone's wrists and keyboards in the long-run.
[editline]0[/editline]
and sanity
[QUOTE=i300;21841955]Oh, thinking about the graph i use in math every day, your right. X is a column. :downswords:
So I would do this:
[cpp]
// What do i plot?
[/cpp][/QUOTE]
You plot a line from the previous pixelX and pixelY to the current pixelX and pixelY. This means that you have to store them.
[QUOTE=CarlBooth;21842434]I'm thinking of starting Argument Archive® ...it will scan new posts in WAYWO and if it detects an argument we've had before it will link to the previous outcome.
I think it will be better for everyone's wrists and keyboards in the long-run.[/QUOTE]
Don't forget the ragged scraps of sanity that we possess!
[QUOTE=TheBoff;21842501]Don't forget the ragged scraps of sanity that we possess![/QUOTE]
[QUOTE=CarlBooth;21842434][editline]0[/editline]
and sanity[/QUOTE]
:ninja:
making an entity class in sfml
CEntity.h
[cpp]
#include <sfml/Graphics.hpp>
#include <string>
#include <iostream>
class CEntity
{
public:
bool SetSprite(std::string fileName);
bool SetCollisionEnabled(bool isCollisionEnabled);
void SetStartCoordinates(float xPos, float yPos);
sf::Sprite GetSprite();
sf::Sprite m_Sprite;
sf::Image m_Image;
float x, y;
private:
};
[/cpp]
CEntity.cpp
[cpp]
#include "CEntity.h"
bool CEntity::SetCollisionEnabled(bool isCollisionEnabled)
{
return true;
}
bool CEntity::SetSprite(std::string fileName)
{
if(!CEntity::m_Image.LoadFromFile(fileName))
{
return false;
}
else
{
CEntity::m_Sprite.SetImage(m_Image);
CEntity::m_Sprite.SetX(CEntity::x);
CEntity::m_Sprite.SetY(CEntity::y);
return true;
}
}
void CEntity::SetStartCoordinates(float xPos, float yPos)
{
CEntity::x = xPos;
CEntity::y = yPos;
}
sf::Sprite CEntity::GetSprite()
{
return CEntity::m_Sprite;
}
[/cpp]
main.cpp
[cpp]
#include "CEntity.h"
#include <iostream>
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
CEntity spriteTest;
spriteTest.SetStartCoordinates(10.f, 10.f);
spriteTest.SetSprite("test.png");
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
if (Event.Type == sf::Event::KeyPressed)
{
if (Event.Key.Code == sf::Key::Escape)
App.Close();
if (Event.Key.Code == sf::Key::F1)
{
sf::Image Screen = App.Capture();
Screen.SaveToFile("screenshot.jpg");
}
}
}
App.Clear();
App.Draw(spriteTest.GetSprite());
App.Display();
}
return EXIT_SUCCESS;
}
[/cpp]
Anything wrong with what i have so far?
Table support:
[img]http://img338.imageshack.us/img338/6240/tableplottingsupport.png[/img]
Also works in 3D if you add a Z coordinate and use "plot3lines" instead of "plot2lines"
[editline]05:11PM[/editline]
(oh and you can load/save to CSV, which makes Excel exporting/importing easy)
[QUOTE=nullsquared;21843056]Table support:
[img]http://img338.imageshack.us/img338/6240/tableplottingsupport.png[/img]
Also works in 3D if you add a Z coordinate and use "plot3lines" instead of "plot2lines"
[editline]05:11PM[/editline]
(oh and you can load/save to CVS, which makes Excel exporting/importing easy)[/QUOTE]
Show this to your school and you'll instantly become the new system administrator.
Next up on WAYWO v10: nullsquared's grapher now walks your dog, does your homework, and cures cancer. Simultaneously.
In seriousness, I think your grapher can do more things than the graphing portion of my calculator. Maybe.
[QUOTE=helpiminabox;21843204]In seriousness, I think your grapher can do more things than the graphing portion of my calculator. Maybe.[/QUOTE]
My calculator can't even graph. I love Calky though, I got him when I was like one year old, and have been best friends ever since!
Can someone show me how to do collision in SFML? or at least give me some math to get me started
[QUOTE=helpiminabox;21843204]Next up on WAYWO v10: nullsquared's grapher now walks your dog, does your homework, and cures cancer. Simultaneously.
In seriousness, I think your grapher can do more things than the graphing portion of my calculator. Maybe.[/QUOTE]
You're right, I wish my calculator would do implicit graphing. That would be really useful.
[QUOTE=raccoon12;21843304]Can someone show me how to do collision in SFML? or at least give me some math to get me started[/QUOTE]
What kind of collision? Boxes, per-pixel, ...?
[QUOTE=raccoon12;21843044]making an entity class in sfml
Anything wrong with what i have so far?[/QUOTE]
I can't work out what you're trying to do with this method
[cpp]bool CEntity::SetCollisionEnabled(bool isCollisionEnabled)
{
return true;
}[/cpp]
How come you're passing in a bool and doing nothing with it?
Maybe you mean something like
[cpp]inline void SetCollision(bool value) { m_collision = value; }[/cpp]
because most of them methods you have make no sense, as far as i can see.
[QUOTE=raccoon12;21843304]Can someone show me how to do collision in SFML? or at least give me some math to get me started[/QUOTE]
What types of collisions are you looking for? If it's just circle -> circle, then you just need a simple check to see whether the center of each circle is closer than the sum of the radii.
It gets a bit more confusing when you are looking at polygons though.
[QUOTE=layla;21843370]I can't work out what you're trying to do with this method
[cpp]bool CEntity::SetCollisionEnabled(bool isCollisionEnabled)
{
return true;
}[/cpp]
How come you're passing in a bool and doing nothing with it?
Maybe you mean something like
[cpp]inline CEntity::SetCollision(bool value) { m_collision = value; };[/cpp]
because most of them methods you have make no sense, as far as i can see.[/QUOTE]
I'm bored, so I don't even know what I'm doing
also, I'm just trying new stuff and figuring out classes
Also, I'm not done with the Collision function
[editline]04:26PM[/editline]
[QUOTE=Overv;21843357]You're right, I wish my calculator would do implicit graphing. That would be really useful.
What kind of collision? Boxes, per-pixel, ...?[/QUOTE]
per pixel
[QUOTE=Dlaor;21843174]Show this to your school and you'll instantly become the new system administrator.[/QUOTE]
In my experience, network administration has very little to do with advanced mathematics and graphing equations!
[QUOTE=raccoon12;21843044]making an entity class in sfml
[cpp]
bool CEntity::SetSprite(std::string fileName)
{
if(!CEntity::m_Image.LoadFromFile(fileName))
{
return false;
}
else
{
CEntity::m_Sprite.SetImage(m_Image);
CEntity::m_Sprite.SetX(CEntity::x);
CEntity::m_Sprite.SetY(CEntity::y);
return true;
}
}
[/cpp]
Anything wrong with what i have so far?[/QUOTE]
You need to make some sort of manager for loading sf::Images. If you have multiple entities with the same sf::Image, you're going to waste memory because each class will have it's own image.
[QUOTE=Turd92;21843469]You need to make some sort of manager for loading sf::Images. If you have multiple entities with the same sf::Image, you're going to waste memory because each class will have it's own image.[/QUOTE]
Hm
how would I go about doing that
[QUOTE=CarlBooth;21843450]In my experience, network administration has very little to do with advanced mathematics and graphing equations![/QUOTE]
Yeah I was about to say that but decided to go against stating the obvious :v: My school does know about it, though :smug:
[editline]05:34PM[/editline]
I'm actually also not only doing this for the usefulness, but as a project to get me into the best college possible.
[QUOTE=raccoon12;21843044]making an entity class in sfml
--snipcode--
Anything wrong with what i have so far?[/QUOTE]
Take/Return (const) references.
Slap accessors on it. Encapsulation 'n stuff.
In general it's easier if you abstract types of other libraries away. If you're just looking to "make a game, not an engine" and are settled for SFML for sure, then it's fine tho.
I guess CEntity is supposed to be a base-type to derive other types from. As such, make the functions (purely) virtual. And create a virtual destructor! Short non-virtual functions could be inlined (precondition: the function is defined when declared, i.e. definition is present in the header).
Why are you explicitly using the scoping-operator for some members, but not for others? And why are some members prefixed with m_, but not others?
Try not to create variables in loops, it's more efficient to create them outside since they will prevail and not get destroyed each time the loop 're-loops'.
You could use switch for Event.Type and Event.Key.Code. It's more readable IMO and easier extendable.
Depending on the complexity of your game it might be easier to create an event-system rather than hardwiring each key to a function in the mainloop.
Does SFML clean itself/its resources up?
[QUOTE=raccoon12;21843421]
per pixel[/QUOTE]
I think a good method would be to use a bounding box and then use GetPixel to check for collisions in the overlapping area.
[QUOTE=quincy18;21832171]Well I haven't posted in a while, been lurking the waywo threads since v3
It seems I can never finish stuff :(
Here is my C#/XNA tile-engine + camera :
[IMG_THUMB]http://img1.uploadscreenshot.com/images/orig/5/12806441945-orig.jpg[/IMG_THUMB]
It currently features transparent tiles and multiple layer, panning and zooming.
Also have neural network laying around that just needs some interfacing with xna, and a little p2p program I'm working on, got it to connect to the server and ask for a peer list.[/QUOTE]
I realize I'm like two pages late to this, but you should seriously consider changing the name to [i][b]Mine Your Own Business[/b][/i] :v:
[QUOTE=nullsquared;21843613]Yeah I was about to say that but decided to go against stating the obvious :v: My school does know about it, though :smug:
[editline]05:34PM[/editline]
I'm actually also not only doing this for the usefulness, but as a project to get me into the best college possible.[/QUOTE]
I don't know whether it will be anything like the same in the states but Cambridge (who gave me an offer!) wanted me to have done maths, and asked me only maths and logic questions at interview. Plus there was not that much of a space in the english system for a portfolio: I didn't have space to talk about anything I'd done in any great detail, and they didn't ask me anyway.
[editline]10:46PM[/editline]
And I have ended up doing A LOT of maths!
[QUOTE=raccoon12;21843511]Hm
how would I go about doing that[/QUOTE]
I'd do it like this:
[cpp]
class ImageManager
{
public:
static sf::Image *Get( const std::string &path );
static void Release( const std::string &path );
static void ReleaseAll( void );
private:
static std::map< std::string, sf::Image * > images;
};[/cpp]
Pass a path to Get, and it should check if images[ path ] exists. If it doesn't, load it from file, insert it into the map and return the image.
Pass a path to Release and it should release images[ path ] if it exists. If you're done using an image (and you're sure), you can release a specific image. It's generally not worth releasing it if there's a possibility you'll use it again.
ReleaseAll should release every image stored in images. You'll generally want to use that just before the game closes, so that no memory is leaked.
You could do away completely with ReleaseAll if you use smart pointers.
Well I finished my JamLegend bot, 100%ed a difficult song and one guy is already accusing me of bot using :(
Am I a bad person?
No, Now lets see this bot!
[QUOTE=Turd92;21843998]I'd do it like this:
[cpp]
class ImageManager
{
public:
static sf::Image *Get( const std::string &path );
static void Release( const std::string &path );
static void ReleaseAll( void );
private:
static std::map< std::string, sf::Image * > images;
};[/cpp]
Pass a path to Get, and it should check if images[ path ] exists. If it doesn't, load it from file, insert it into the map and return the image.
Pass a path to Release and it should release images[ path ] if it exists. If you're done using an image (and you're sure), you can release a specific image. It's generally not worth releasing it if there's a possibility you'll use it again.
ReleaseAll should release every image stored in images. You'll generally want to use that just before the game closes, so that no memory is leaked.
You could do away completely with ReleaseAll if you use smart pointers.[/QUOTE]
Does SFML not do this for you?
If it does not I'd also recommend a hashmap over a normal map for strings.
[QUOTE=Maurice;21844048]Well I finished my JamLegend bot, 100%ed a difficult song and one guy is already accusing me of bot using :(
Am I a bad person?[/QUOTE]
I always thought that it's OK to cheat if you made your own cheat since you spent your time programing instead of practicing the game you want to cheat.
[editline]12:18AM[/editline]
[IMG]http://lh6.ggpht.com/_ZoH0ul2PquE/S-cz5-2_L5I/AAAAAAAAAa4/sC15s267E30/Fading.jpg[/IMG]
Those orange shapes are circles drawn in OpenGL using the triangle fan. They are supposed to fade out but they seem to start fading on the edges and then later in the middle until they disappear.
This is the code I use to draw a circle:
[cpp]
Gl.glEnable( Gl.GL_BLEND );
Gl.glBlendFunc( Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA );
Gl.glBegin( Gl.GL_TRIANGLE_FAN );
Gl.glColor4f( Color.R, Color.G, Color.B, Color.A );
Gl.glVertex2f( Center.X, Center.Y );
int i = 0;
while ( i < 360 ) {
Gl.glColor4f( Color.R, Color.G, Color.B, Color.A );
Gl.glVertex2f( Center.X + (float)Math.Sin( i ) * Radius, Center.Y + (float)Math.Cos( i ) * Radius );
i += 10;
}
Gl.glEnd();
Gl.glDisable( Gl.GL_BLEND );[/cpp]
Any idea what I'm doing wrong?
(I can upload the whole thing if the pic doesn't explain what I'm talking about.
[QUOTE=ZeekyHBomb;21844267]Does SFML not do this for you?
If it does not I'd also recommend a hashmap over a normal map for strings.[/QUOTE]
I'm pretty sure it doesn't. I just double checked the source and found nothing.
And thanks for the tip :smile:
Oh did I mention it can plot a table as a set of points and also compute linear regression?
[code]
plot2points points
linear2fit points
[/code]
[img]http://img23.imageshack.us/img23/669/linearregression1.png[/img]
[QUOTE=nullsquared;21845476]Oh did I mention it can plot a table as a set of points and also compute linear regression?
[code]
plot2points points
linear2fit points
[/code]
[img]http://img23.imageshack.us/img23/669/linearregression1.png[/img][/QUOTE]
Awesome.
Can it plot the answer to life, the universe, and everything? [sp]42[/sp]
Sorry, you need to Log In to post a reply to this thread.