[QUOTE=Jookia;37727913]Why not just have a 2D array that can expand/contract X or Y and set the unused parts to NULL?[/QUOTE]
Would probably waste too much memory. In the worst case it could be a very degenerate graph with dozens of rows that are mostly empty.
[QUOTE=laylay;37727860]The client has packet handlers, the packet handler deserializes the packet and calls a client event with that data read from the packet, that way any game state can register client event handlers and do whatever with that data. The problem is that it's a really shit solution for packets that contain lots of data (like a snapshot of every entity on the server) The multiplayer game state has to create the game entities so it has to get that data somehow without client knowing anything about the game state. It's a tricky thing to design elegantly.
It wouldn't be a problem if the game states could deserialize packets but i felt that it should be handled in client and not game states.[/QUOTE]
You mean the multiplayer state is missing information on interdependent entities while the client is deserializing the list?
In C# I'd probably make a map from entity ids to a list of delegates that fill in the fields once the entity is available. I'd be surprised if that was more complicated in C++.
You'd need a switch in the multiplayer state that ensures it's not going to simulate a partial state and that the queue is empty at the end of the packet.
You could also add a storage for partially initialized entities to defer activation past the current frame, if you ensure that they don't stall indefinitely.
[editline]20th September 2012[/editline]
You could probably just throw everything into a queue and execute that at the end of the packet, if you care more about speed than memory and don't want to queue past the current frame.
Is there a way to tell Arduino to round off numbers to the nearest ten?
[QUOTE=lawlavex;37730200]Is there a way to tell Arduino to round off numbers to the nearest ten?[/QUOTE]
I'm not sure about the specific round functions available to arduino but you want something like this:
[cpp]round(num / 10.0f) * 10.0f;[/cpp]
fixed
[CODE]import java.util.*;
public class testSumSquares
{
static int x;
static int y;
public static void main(String[] args)
{
Scanner userInput = new Scanner(System.in);
System.out.println("Enter first integer: ");
x = userInput.nextInt();
System.out.println("Enter second integer: ");
y = userInput.nextInt();
System.out.println(SumSquares(x,y));
}
public static int SumSquares(int x,int y)
{
int finalSum = 0;
// Make sure that first int is lower than second
int holdVal;
if(y > x)
{
holdVal = x;
x = y;
y = holdVal;
}
int arraySize = y - x;
int sqr[] = new int[arraySize];
for(int i = 1; i <= sqr.length + 1; i++)
{
finalSum += (i * i);
}
return finalSum;
}
}[/CODE]
You could just do x - y, then take the absolute value of that.
Also, what the fuck is the point of the sqr array? You're not doing anything with it so why not just take the value of x - y?
I can't even tell what that function is supposed to do.
I'm having a problem in Adobe Flash with Actionscript 3.
I'm going to have a bunch of game-characters on the screen at some point, and I want to write my classes in anticipation of this.
Basically, I'm coding a 'shadow-trigger' class that sits on top of the graphical game world wherever there are shadows. The trigger is just a basic box-shaped MovieClip. When a character moves into this trigger, their colour is transformed darker to reflect this, then this is reverted when they leave the trigger.
So I figured the best way to do this would be to code the ShadowTrigger class with code that detects the object that's collided with it then applies the colourTransform code to the object.
But how do I apply code to objects that are children of the same parent as the shadowtrigger class? Normally if it was an interaction between two classes that must exist for the other to work, I'd do something like
[QUOTE](this.parent as MovieClip).target.colourTransform.(...)[/QUOTE]
but besides being (as far as I'm aware) a non-ideal way of coding in the first place, it doesn't allow me to deal with detecting different instances of objects.
What do you guys think?
So, I have a map of tiles in my SFML game, but the game is running in like 3fps...
thats ok, im rendering a lot of tiles in a for.
I want to create a image with all the tiles,
the best way to do that is with something like
tile.loadFromFile("tile.jpg"));
image.create(20, 20, sf::Color::Black);
image.copy(tile, 10, 10);
running in a loop obviously.. ?
I have read that copy use a lot of resource from the machine, I will update the "image" constantly.
For some reason, my android application do not render anything if I save a reference to the OpenGL GL10 object and use it for doing the renderer stuff. Maybe I am running it in another thread or something. Do anyone know how to fix it?
Better solution: only render the tiles that are visible
[QUOTE=robmaister12;37746995]Better solution: only render the tiles that are visible[/QUOTE]
all tiles are visible
[QUOTE=Mete;37746878]So, I have a map of tiles in my SFML game, but the game is running in like 3fps...
thats ok, im rendering a lot of tiles in a for.
I want to create a image with all the tiles,
the best way to do that is with something like
tile.loadFromFile("tile.jpg"));
image.create(20, 20, sf::Color::Black);
image.copy(tile, 10, 10);
running in a loop obviously.. ?
I have read that copy use a lot of resource from the machine, I will update the "image" constantly.[/QUOTE]
Wouldn't it be easier to just use a rendertexture and draw the tiles to that?
[QUOTE=ace13;37747339]Wouldn't it be easier to just use a rendertexture and draw the tiles to that?[/QUOTE]
Thats probably what Im trying to do.
Thanks for the tip.
How do you detect if a std::unique_ptr's object is null? For instance if I have a std::unique_ptr< char >, how do I detect that the char is not defined?
...Dereference it and check against null?
[QUOTE=esalaka;37749890]...Dereference it and check against null?[/QUOTE]
I'm really amazingly stupid, so could you spell it out?
Wait, I wasn't thinking.
Do you want to check if the pointer points to null? For pre-C++11 it's simply if (p == NULL) and for the current standard if (p == nullptr)
[editline]21st September 2012[/editline]
"Points to null" as opposed to "points to an actual memory address"
[QUOTE=esalaka;37750446]Wait, I wasn't thinking.
Do you want to check if the pointer points to null? For pre-C++11 it's simply if (p == NULL) and for the current standard if (p == nullptr)
[editline]21st September 2012[/editline]
"Points to null" as opposed to "points to an actual memory address"[/QUOTE]
I'm not sure I have a clue what I'm doing (so I probably don't), but I want to check if the char that std::unique_ptr points to is defined, or is NULL yes.
[QUOTE=T3hGamerDK;37751267]I'm not sure I have a clue what I'm doing (so I probably don't), but I want to check if the char that std::unique_ptr points to is defined, or is NULL yes.[/QUOTE]
I'm not sure what you mean with 'defined'. That the pointer has not yet been assigned a value? Then, yes, you compare it with the NULL constant, which is the default state of uninitialized pointers.
[QUOTE=Eudoxia;37755497]I'm not sure what you mean with 'defined'. That the pointer has not yet been assigned a value? Then, yes, you compare it with the NULL constant, which is the default state of uninitialized pointers.[/QUOTE]
NULL isn't default, it can point to anything. You need to set it to NULL when you create it or delete it.
[QUOTE=Eudoxia;37755497]I'm not sure what you mean with 'defined'. That the pointer has not yet been assigned a value? Then, yes, you compare it with the NULL constant, which is the default state of uninitialized pointers.[/QUOTE]
Ah, yes, I understand now. Thanks a bunch all of you!
Just downloaded Visual Studio Express 2012 for Windows Desktop. Unlike previous versions, it seems to bundle the languages in one package. What I'm wondering is, is this supposed to come without F# tools? Do I need to get Professional to develop in F#?
Edit: Never mind, I just noticed I got the Pro version through Dreamspark :v:
[QUOTE=T3hGamerDK;37749756]How do you detect if a std::unique_ptr's object is null? For instance if I have a std::unique_ptr< char >, how do I detect that the char is not defined?[/QUOTE]
if(!ptr)
What are the capibilities of Visual Basic? Got a computer programming class and that is all we use.
kinda wanna impress my teacher.
[QUOTE=Mysterious Mr.E;37759676]What are the capibilities of Visual Basic? Got a computer programming class and that is all we use.
kinda wanna impress my teacher.[/QUOTE]
You can do anything that you can in another Turing-complete language.
Ok, so I'm learning Java in computer science at school
I've been working on this for like 10 minutes and I can't figure out
[php] for (int x = 0, y = 0; x <= 300 && y <= 200; x +=15, y += 10) {
// colla = new Color(((int)(1 + Math.random() * 200)),((int)(1 + Math.random() * 200)),((int)(1 + Math.random() * 200)));
// g.setColor(colla);
// Quadrants
// 1st
g.drawLine(300,y,300+x,200);
// 2nd
g.drawLine(300,y,300-x,200);
// 3rd
g.drawLine(300,200+y,x,200);
// 4th
g.drawLine(300,200+y,300+x,200);
}[/php]
Why the fuck won't quad 4 work.
[img]https://dl.dropbox.com/u/6380033/ZScreen/qaud4fucked.PNG[/img]
g.drawLine(300+x, 200, 300, 400-y);
I have a set of points that form a curve, and I am looking to make a sprite out of the curve. It should be like an island, with a texture that loops. Any tips?
I guess I can have a rectangled texture that overlaps the entire shape, and then go into the texture-data to check which pixels overlap the shape, and then make those pixels transparent?
I would also want to have some sort of anti-aliasing in there somehow.
Probably not understanding the question but just triangulate the polygon made from the points?
So... Anyone knows how compilers traditionally implement namespaces?
Sorry, you need to Log In to post a reply to this thread.