Well I guess I found you another flaw you gotta fix :V
[editline]28th November 2010[/editline]
For some reason the player, on the second tick, teleports like 500 pixels down into the ground. I have no idea why. I set up breakpoints in the move function (the only one that control's the player's co ordinates) and it happend right after the end of it, but before the beginning. Here is the main function:
[code]int main(){
App.ShowMouseCursor(false);
mainch.mainchinventory.read();
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
}
float time = App.GetFrameTime();
mainch.move(time);
App.Clear();
drawall();
App.Display();
}
return EXIT_SUCCESS;
}[/code]
And the move function:
[code]void cmainchar::move(float t){
if (App.GetInput().IsKeyDown(sf::Key::S)) mainchinventory.save();
if (App.GetInput().IsKeyDown(sf::Key::R)) mainchinventory.read();
if (App.GetInput().IsKeyDown(sf::Key::A)) A = true;
else A = false;
if (App.GetInput().IsKeyDown(sf::Key::D)) D = true;
else D = false;
if(grounded)
if (App.GetInput().IsKeyDown(sf::Key::W)) first = true;
if ((App.GetInput().IsKeyDown(sf::Key::I)) && (keyreleased)){
if (mainchinventory.drawmain){
mainchinventory.drawmain = false;
mainchinventory.press(mainchinventory.selectionx, 3);
}
else{
mainchinventory.drawmain = true;
}
keyreleased = false;
}
else if (!App.GetInput().IsKeyDown(sf::Key::I))
keyreleased = true;
if(!mainchinventory.drawmain){
if(App.GetInput().IsKeyDown(sf::Key::Num1)) mainchinventory.press(0, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num2)) mainchinventory.press(1, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num3)) mainchinventory.press(2, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num4)) mainchinventory.press(3, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num5)) mainchinventory.press(4, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num6)) mainchinventory.press(5, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num7)) mainchinventory.press(6, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num8)) mainchinventory.press(7, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num9)) mainchinventory.press(8, 3);
else if(App.GetInput().IsKeyDown(sf::Key::Num0)) mainchinventory.press(9, 3);
if(App.GetInput().IsMouseButtonDown(sf::Mouse::Button::Left)){
mainchinventory.dockitems[mainchinventory.selectionx].use();
spells.push_back(cspell());
}
}
else if ((App.GetInput().IsMouseButtonDown(sf::Mouse::Button::Left)) && (mainchinventory.drawmain) && (buttonreleased)){
mainchinventory.checkmouse();
buttonreleased = false;
}
else if (!App.GetInput().IsMouseButtonDown(sf::Mouse::Button::Left))
buttonreleased = true;
int xmap = (View.GetCenter().x - 320) / 40;
int ymap = (View.GetCenter().y - 240) / 40;
if ((xmap != xmapold) || (ymap != ymapold))
maps.read();
xmapold = xmap;
ymapold = ymap;
collisions();
for(std::list<cspell>::iterator i = mainch.spells.begin(); i != mainch.spells.end(); i++)
if (i->move(t))
spells.erase(i);
if (A && left){
animate(2, t);
you.Move(-160 * t, 0);
}
if (D && right){
animate(1, t);
you.Move(160 * t, 0);
}
if (!D && !A)
animate(0, t);
if (up){
if(grounded && first){
jump = 1.25;
first = false;
}
if (jump > 0){
you.Move (0,-250 * t * jump);
jump = jump - 1 * t;
}
if (jump <= 0){
jump = 0.f;
}
}
else{
first = false;
jump = 0.f;
}
if (down){
fall = fall + 10 * t;
you.Move(0, 25 * fall * t);
grounded = false;
}
else{
fall = 0.f;
grounded = true;
}
if(teleport){
mainchinventory.spawn = true;
fall = 0.f;
jump = 0.f;
maps.changemap(maps.nxtmap);
teleport = false;
}
moveview();
}[/code]
No one know about my question?
[QUOTE=bobthe2lol;26373337]No one know about my question?[/QUOTE]
Wait a little more than 25 minutes. And no, the only 2 other people here code in C++ (or at least I don't think Richy knows C#).
I know a little bit of C# but not any networking
[QUOTE=Richy19;26373633]I know a little bit of C# but not any networking[/QUOTE]
Incedentaly, my question isnt about networking.
Im kinda tired so cant concentrate too much but
is this meant to be -250?
[cpp]
if (up){
if(grounded && first){
jump = 1.25;
first = false;
}
if (jump > 0){
you.Move (0,-250 * t * jump);
jump = jump - 1 * t;
}
if (jump <= 0){
jump = 0.f;
}
}[/cpp]
If it is i can only assume its making a gravity effect.
Seems very strange that it happens after the move has finished tho.
Oh wait are you using the same system as i am?
print the players position to the console and make sure that they are were they should be first.
[editline]29th November 2010[/editline]
[QUOTE=bobthe2lol;26373718]Incedentaly, my question isnt about networking.[/QUOTE]
True, as i said all i can see is that the program isnt allowed to access the memory so the only thing i can think of is taht you might have to run it as admin.
But best thing is to wait until tomorrow when most of the regulars come online
[QUOTE=Richy19;26373738]Im kinda tired so cant concentrate too much but
is this meant to be -250?
[cpp]
if (up){
if(grounded && first){
jump = 1.25;
first = false;
}
if (jump > 0){
you.Move (0,-250 * t * jump);
jump = jump - 1 * t;
}
if (jump <= 0){
jump = 0.f;
}
}[/cpp]
If it is i can only assume its making a gravity effect.
Seems very strange that it happens after the move has finished tho.
Oh wait are you using the same system as i am?
print the players position to the console and make sure that they are were they should be first.
[editline]29th November 2010[/editline]
True, as i said all i can see is that the program isnt allowed to access the memory so the only thing i can think of is taht you might have to run it as admin.
But best thing is to wait until tomorrow when most of the regulars come online[/QUOTE]
-250 will make you go up, not down. And like I said, when the player first spawns (first tick) they are at their needed position. So at first its 520, 220. Next frame/tick it's 520, -3042. I don't know why it is negative now, but the problem stands.
Dont know really theres nothing there that i can see would do that.
Unless the frame time is malfunc and is passing through a high number that makes it go straight down
Wait no why doesn't it happen during the function? As I said, the breakpoints say it is AFTER the function.
well thats the problem, if your player moves to much on one tick it completelly jumps the box and hence theres no intersection
But can you post the collision code?
[QUOTE=Richy19;26374257]well thats the problem, if your player moves to much on one tick it completelly jumps the box and hence theres no intersection
But can you post the collision code?[/QUOTE]
Oh wait I see what you are saying. I did some tests and it seems to be because of the jump function.
[editline]28th November 2010[/editline]
WOOP I FIXED IT! It was because of the fall/jump was being set to high numbers from being saved. Now I set it to be only read unless it isn't jumping.
Would anyone know how to use the Samples array in SFML.Audio.SoundBuffer?
Specifically, how to map each sample to a time.
I am very new to C++, and am just curious on how I would read what a user inputted into an std::cin. More specifically, check whether or not what they inputted was something specific.
Check out this page: [url]http://www.cplusplus.com/doc/tutorial/basic_io/[/url]
It will teach you the basics of I/O with cin/cout.
[QUOTE=Richy19;26372458][cpp]for(int i = 0 ; i < treeint; i++ )
{
Tree.SetPosition(trees[i].x,trees[i].y );
if(sf::FloatRect( Warrior.getSolidRect() ).Intersects( Tree.getSolidRect() ) )
{
intersects = true ;
Warrior.SetPosition(warriorPos);
}
}
if(!intersects)
{
warriorPos = Warrior.GetPosition();
Warrior.Move(Warrior.getDirection(0) * App.GetFrameTime(), Warrior.getDirection(1) * App.GetFrameTime() );
}
Warrior.setDirection(0,0);
Warrior.setDirection(0,1);
intersects = false;
[/cpp]
Thats pretty much all the collision detection i use, note that this uses SFML so will only be valid if you implement those features or are using SFML[/QUOTE]
You do realize that FloatRect.Intersects does not works if your object has a very high speed, right ?
I'm uploading a file with FTP in C#, how do I bzip it first and upload the bzipped file? This is for a fastdl updater by the way.
This is what I'm doing currently:
[code]
Console.WriteLine("Creating FTP object.");
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(addr + e.Name); // create and caste it!
req.Method = WebRequestMethods.Ftp.UploadFile;
req.Credentials = new NetworkCredential(user, pass);
req.UsePassive = true;
req.UseBinary = true;
req.KeepAlive = false;
Console.WriteLine("Reading file.");
FileStream stream = new FileStream(e.FullPath, FileMode.Open);
byte[] buff = new byte[stream.Length];
stream.Read(buff, 0, buff.Length);
stream.Close();
Console.WriteLine("Sending File.");
Stream req_stream = req.GetRequestStream();
req_stream.Write(buff, 0, buff.Length);
req_stream.Close();
FtpWebResponse response = (FtpWebResponse)req.GetResponse();
Console.WriteLine("Upload File Complete.\n{0}", response.StatusDescription);
response.Close();
[/code]
[QUOTE=Kill coDer;26382774]I'm uploading a file with FTP in C#, how do I bzip it first and upload the bzipped file? This is for a fastdl updater by the way.
This is what I'm doing currently:
[code]
Console.WriteLine("Creating FTP object.");
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(addr + e.Name); // create and caste it!
req.Method = WebRequestMethods.Ftp.UploadFile;
req.Credentials = new NetworkCredential(user, pass);
req.UsePassive = true;
req.UseBinary = true;
req.KeepAlive = false;
Console.WriteLine("Reading file.");
FileStream stream = new FileStream(e.FullPath, FileMode.Open);
byte[] buff = new byte[stream.Length];
stream.Read(buff, 0, buff.Length);
stream.Close();
Console.WriteLine("Sending File.");
Stream req_stream = req.GetRequestStream();
req_stream.Write(buff, 0, buff.Length);
req_stream.Close();
FtpWebResponse response = (FtpWebResponse)req.GetResponse();
Console.WriteLine("Upload File Complete.\n{0}", response.StatusDescription);
response.Close();
[/code][/QUOTE]
Look how Bzip does it and then find relevant bindings for C#?
[editline]29th November 2010[/editline]
Er, the compressing, obviously
[QUOTE=Zenith;26380322]You do realize that FloatRect.Intersects does not works if your object has a very high speed, right ?[/QUOTE]
[QUOTE=Richy19;26374257]well thats the problem, if your player moves to much on one tick it completelly jumps the box and hence theres no intersection
But can you post the collision code?[/QUOTE]
I hate Selectors.
[code]
New connection from: Socket[addr=/127.0.0.1,port=59735,localport=25565]
java.nio.channels.IllegalBlockingModeException
[/code]
I know it's my _serverSocket.accept() but, why does my selector keep giving me already accepted sockets?
[code]
if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT) {
Socket socket = _serverSocket.accept();
SocketChannel socketChannel = socket.getChannel();
socketChannel.configureBlocking(false);
// Register it with the selector, for reading
socketChannel.register(_selector, SelectionKey.OP_READ);
// Call the event
_serverEventListener.onAccept(socket, socketChannel);
}
[/code]
Edit:
Solved; Oracle needs to fix their documentation "(optional operation)" isn't so optional.
ios::binary doesn't seem to do a thing for fstreams, really.
The streaming operators do formatted i/o and the read and write functions binary i/o.
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
Okay, so I'm working on a very basic scripting language, and I use commas as separators between the parameters using boost's split function with the condition of boost::is_any_of( "," ). How would I go about creating escape sequences like \, \> \: which are all used by my parser? So I could have something like:
"std>printl:When you see this symbol\: \>\, it is the prefix of a method from a owner.;" without it breaking.
Split by boost::is_any_of(":;") (some other stuff might be required, so it won't screw up when using : instead of ; and the other way around, but this is the basic idea) and then only split the first any every other following by ",".
why would a call to std::cout fix apparent errors with a dynamic array of floating point numbers?
Edit:
only fixes it if the values of the members of the array are printed
Post code.
Also, you can't call an instance, unless maybe if it would overload the operator() or is a function pointer, and neither is true for std::cout. You mean you outputted a member of your array and the array, before somehow damaged (how was it damaged?) got like you want it I presume though.
_snip_
because the problem has apparently fixed itself.
How do I make a destructor for this class?
[code]class cspell{
static sf::Image ispell;
float x, y;
bool move(float);
cspell();
public:
sf::Sprite spell;
void draw();
friend class cmainchar;
};[/code]
Wouldn't it just be ~cspell();?
No but like, what would I put in the destructor? Or would just having a blank one suffice?
I think a blank one would work.
Sorry, you need to Log In to post a reply to this thread.