[QUOTE=Citadis;26870330]yes.[/QUOTE]
So just declare the thing something like std::vector<Int*> intpointers;
For some reason all my incoming UDP packets get their first 4 bytes zeroed. I have no idea why this is happening D:
This code is running in a loop, the buffer is memset to 0 and everything every time data is received.
[img]http://cubeupload.com/files/d50d87untitled.png[/img]
[cpp]
ReceivedBytes = recvfrom( Data->ListenSocket, Buffer, 2048, 0, (SOCKADDR*)&SenderAddr, &SenderAddrSize );
printf( "\nReceived %d bytes\nID\tByte\tChar\n", ReceivedBytes );
for( int i = 0; i < ReceivedBytes; i++ ) {
printf( "#%d\t%d\t%c\n", i, Buffer[i], Buffer[i] ) ;
}
[/cpp]
This is the code that sends the message:
[lua]
local socket = require("socket")
local udp = socket.udp()
udp:sendto("Hello world!", "127.0.0.1", 250)
udp:sendto("Hello there!", "127.0.0.1", 250)
[/lua]
Has any of you ever experienced anything like this?
[QUOTE=Vbits;26869814]I have already implemented it. 3 lines of code that worked first time is not what I call hard, though is there anything that could be a security concern in a really simple webserver + a little hosting trick.[/QUOTE]
You're accepting packets from outside and acting on them? That could be a security concern. Make sure nobody can do anything you don't expect.
I'm trying to create an RPG style attribute list, and get a random effect from that list and apply it. What's the best way to do this in c++, I was just thinking of setting an interger to a random number and check + apply effects based off it but numbers suck + and I want something a little more readable.
Well, have your enum of effects to use inside the program and a string-array of their textual representations to use for the UI.
The end to acting on them is looking it up in a list or a local file that is in one directory. Nothing other then a text file touches the filesystem and that is escaped and read as a string. The only malrious use is the fact they have unrestricted use of html.
Yeah, just remembered enums
-snip- wrong subforum :v:
[QUOTE=Vbits;26869814]though is there anything that could be a security concern in a really simple webserver + a little hosting trick.[/QUOTE]
[b]Yes,[/b] but the port forwarding used to allow incoming connections to the server — whether established manually or automatically via UPnP — isn't it. Any program that accepts data from untrusted sources, e.g. arbitrary remote users, has to be very careful in how it handles its input.
Hmm why would i get [quote]Object reference not set to an instance of an object.[/quote]
on this line?
[cpp]this.previousPosition.Add(this.position);[/cpp]
Where
[cpp]public Vector2 position;
public List<Vector2> previousPosition;[/cpp]
You need to assign them instances of those types. new Vector2 and new List<Vector2>
I don't know much about C#, but don't you need to create them first?
[csharp]public Vector2 position = new Vector2();
public List<Vector2> previousPosition = new List<Vector2>();[/csharp]
[editline]22nd December 2010[/editline]
Damnit Darwin
Haha! I win!
Solved my problem. I was passing the address of a pointer, instead of a pointer to recvfrom, this was due to me using a heap allocated variable earlier, and then switching to memory later, without converting all the code fully.
Has anyone used OpenTK? Can you see if there's anything wrong with my short program? It's copied pretty much straight from [url=https://opentk.svn.sourceforge.net/svnroot/opentk/trunk/Source/Examples/OpenGL/3.x/HelloGL3.cs]an official example[/url], but it's using like 50% of my CPU :psyduck:
[url]http://pastebin.com/pKeaPsah[/url]
Is there a way to compare names of really any data type? Like compare the name of an int to another int? Because I am trying to make an entity manager that will have a list of sf::Sprites and I will do all collision handling there, but I need it to be differentiated which sprite is which. I was thinking maybe make a new class that has an sf::Sprite and an integer that stores what type of entity it is?
What do you mean by the name of a data type?
And why do you need to know anything further than the image-data for collision?
[QUOTE=ZeekyHBomb;26881513]What do you mean by the name of a data type?
And why do you need to know anything further than the image-data for collision?[/QUOTE]
So that if a say projectile collides with a player, the player will take damage. Actually never mind I think I got it. Quick question, if you get classes who inherit from a base class, can you call upon them using their base class? Like if I have class Parent class and an inherit class called Child class, can I make a function that take in Parent class and then put in Child class? So something like this:
[cpp]
class Parent{
};
class Child: public Parent{
};
int Parent(Parent abc){
}
int main(){
Child 123;
Parent(123);
}[/cpp]
[QUOTE=WTF Nuke;26882069]So that if a say projectile collides with a player, the player will take damage. Actually never mind I think I got it. Quick question, if you get classes who inherit from a base class, can you call upon them using their base class? Like if I have class Parent class and an inherit class called Child class, can I make a function that take in Parent class and then put in Child class? So something like this:
[cpp]
class Parent{
};
class Child: public Parent{
};
int Parent(Parent abc){
}
int main(){
Child 123;
Parent(123);
}[/cpp][/QUOTE]
I'm pretty sure you can't, but you can do this
[cpp]
Parent *abc = new Child;
[/cpp]
[QUOTE=Z_guy;26882404]I'm pretty sure you can't, but you can do this
[cpp]
Parent *abc = new Child;
[/cpp][/QUOTE]
I tested it and you can. Was going to snip, but facepunch died on me.
[QUOTE=WTF Nuke;26882449]I tested it and you can. Was going to snip, but facepunch died on me.[/QUOTE]
Oh, I totally misread your code, because of the confusing naming. I thought the Parent(123) thing was a constructor.
[QUOTE=Z_guy;26882503]Oh, I totally misread your code, because of the confusing naming. I thought the Parent(123) thing was a constructor.[/QUOTE]
Yeah sorry about that. Couldn't make up any constructive names on the spot :downs:
I'm writing an engine using LuaGL, but I'm stuck on view movement.
My camera has a position and an angle, and I find the direction or whatever with this:
[lua]local xr,zr = math.sin(self.ang.y), math.cos(self.ang.y)
return Vector(xr, 0, zr)[/lua]
Then, in the movement code I use that and modify the position with it:
[lua]if c == iup.K_s then
local v = Cam:Norm() --The function above
Cam.pos.x = Cam.pos.x - v.x * Cam.speed
Cam.pos.y = Cam.pos.y - v.y * Cam.speed
Cam.pos.z = Cam.pos.z - v.z * Cam.speed
end
if c == iup.K_w then
local v = Cam:Norm()
Cam.pos.x = Cam.pos.x + v.x * Cam.speed
Cam.pos.y = Cam.pos.y + v.y * Cam.speed
Cam.pos.z = Cam.pos.z + v.z * Cam.speed
end
if c == iup.K_d then
local v = Cam:Norm()
Cam.pos.x = Cam.pos.x - v.z * Cam.speed
Cam.pos.y = Cam.pos.y + v.y * Cam.speed
Cam.pos.z = Cam.pos.z + v.x * Cam.speed
end
if c == iup.K_a then
local v = Cam:Norm()
Cam.pos.x = Cam.pos.x + v.z * Cam.speed
Cam.pos.y = Cam.pos.y - v.y * Cam.speed
Cam.pos.z = Cam.pos.z - v.x * Cam.speed
end[/lua]
Sadly, my movement is messed up.
What is the proper way to modify the position?
I don't really know if it's the right place to put this but. I'm starting out in programming, I got some Christmas money i'd like to spend on books to learn, and possibly a program.
What i'm aiming for is to learn how to do 2D games. Problem is I don't know what type of programming to use. C++? Java? I want my first game to be relatively large, so I was thinking C++ would be better. But yeah, any book reccomendations? I'm an absolute beginner at this. All help is appreciated.
Don't use Java.
[QUOTE=yakahughes;26884228]Don't use Java.[/QUOTE]
So what then? C++? 'Cause that's what someone else reccomended.
[QUOTE=DerpHurr;26884260]So what then? C++? 'Cause that's what someone else reccomended.[/QUOTE]
C++, naturally.
Does anyone know of any good lightweight object-oriented C++ GUI libraries that don't require redistributing a DLL and that just wrap the normal Windows API?
[editline]22nd December 2010[/editline]
Also DerpHurr, a lot of people have been recommending and using SFML for 2D game programming, so when you get that far, you should look into that.
C++ with SFML is a good way to go, I know lots of people here use it and will be happy to help with it (me included)
How do I iterate through a list of pointers? I got this so far, but I want to access the members of the pointed objects.
[cpp]for(std::list<centity *>::iterator i = entities.begin(); i != entities.end();){
i.up = true;[/cpp]
[cpp](*i)->up = true[/cpp]
If I understand what you're asking
Basically you deference the iterator pointer to get the centity pointer at that position, then use the pointer operator to set the value of .up to true
.. If that makes any sense. I'm bad at wording these things
Sorry, you need to Log In to post a reply to this thread.