Can anyone spot the logic error in my code for an AI plane?
Here's the code:
[url]http://pastebin.com/ggz7PFKg[/url]
Here's what it actually does:
[url]https://www.youtube.com/watch?v=bJa5nnxixp4[/url]
[QUOTE=Tamschi;40911076]In that case put as many of the most important (longest time since last update/proximity to player) updates into a single UDP packet and send it as often as the connection permits while there is still new data.
Make sure you choose a packet size that isn't split in the network, you can probe for this if you make it discard instead of split afaik.
Put in a sequence number too, that way you can discard outdated updates to a value.
Edit: It's possibly also a good idea to limit the maximum bandwidth, that way you won't have to deal with excessive dropped packets when there are many updates.[/QUOTE]
If you don't feel like making all this on your own, try [url=http://enet.bespin.org/]ENet[/url]. You still need to give packets data, but ENet handles packet splitting and such.
There's also the Steamworks peer-to-peer networking if you're really serious about what you're making.
I've been looking to create a custom audio visualizer for a while. Games like Beat Hazard and Audiosurf have piqued my interest and I want to learn how graphics and audio can come together. I don't have the slightest idea of where to begin in this adventure and I could use some help.
[QUOTE=Emugod;40923306]I've been looking to create a custom audio visualizer for a while. Games like Beat Hazard and Audiosurf have piqued my interest and I want to learn how graphics and audio can come together. I don't have the slightest idea of where to begin in this adventure and I could use some help.[/QUOTE]
I suggest you either read up on Fourier transforms and the like (as a learning excercise) or find some audio transform libraries for your language. That will allow you to split up sound into different frequencies, and divide them into bass, mid and treble. When you have done that, it's up to your imagination really.
Is there a website that gives you simple programming challenges, sort of like Project Euler, but more application based?
[QUOTE=NixNax123;40927698]Is there a website that gives you simple programming challenges, sort of like Project Euler, but more application based?[/QUOTE]
Have you tried hackerrank?
[QUOTE=Chris220;40927715]Have you tried hackerrank?[/QUOTE]
no
[editline]6th June 2013[/editline]
OH GOD THIS IS JUST WHAT I NEEDED THANK YOU
Are there any good tutorials on MonoGame 3D or should I just use XNA 4.0 ones?
I finally decided to use a framework to not let rendering hold me back that much, but I have zero experience with how to properly set up a scene or assets.
[QUOTE=Chris220;40927715]Have you tried hackerrank?[/QUOTE]
is it bad if the first problem is really hard for me
[QUOTE=NixNax123;40928716]is it bad if the first problem is really hard for me[/QUOTE]
Not really, you'll learn by solving it! Feel free to post here if you need a prod in the right direction!
[QUOTE=NixNax123;40928716]is it bad if the first problem is really hard for me[/QUOTE]
Aren't they AI problems or sth
Those aren't exactly the easiest thing to figure out if you've never done them before
[QUOTE=esalaka;40928977]Aren't they AI problems or sth
Those aren't exactly the easiest thing to figure out if you've never done them before[/QUOTE]
I can't even find a character in a vector. find("p") isn't working; it just outputs that it's been found as it iterates through the vector
So I started reworking a lwjgl engine I started a while back, and I was wondering if my current way of rendering geometry is "correct".
I have a Vertex class that holds position and color. A Geometry class has an array of vertices and each bit of geometry has it's own vao, vbo, and ebo. The only kind of actual Geometry I have is the Quad class, which derives from Geometry. In the render function I just do:
[CODE]
glUseProgram(Engine.shaderProgramID); // Use this shader
// Position
glEnableVertexAttribArray(0); // enable the position attribute
glVertexAttribPointer(0, 4, GL_FLOAT, false, 32, 0); // tell opengl how to read the position attribute.
// attribute, amount of elements, type, normalized?, stride, offset ( pointer to first component )
// Color
glEnableVertexAttribArray(1); // enable the color attribute
glVertexAttribPointer(1, 4, GL_FLOAT, false, 32, 12); // tell opengl how to read the color attribute.
// Render using the indices
glDrawElements(GL_TRIANGLES, indices.length, GL_UNSIGNED_BYTE, 0);
// cleanup
glUseProgram(0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
[/CODE]
I feel that this way is pretty good for now, but if there is any way to make it simpler or more efficient, let me know.
Say if I would find a model thats licensensed not to use, which I didn't know had a license and has no evidence of having any (uploader didn't include license files, etc). Would I do illegal stuff or is it the uploader whos at fault for not claiming that its copyrighted work?
[QUOTE=Donkie;40933543]Say if I would find a model thats licensensed not to use, which I didn't know had a license and has no evidence of having any (uploader didn't include license files, etc). Would I do illegal stuff or is it the uploader whos at fault for not claiming that its copyrighted work?[/QUOTE]
You're not allowed to do anything with it unless explicitly permitted.
[editline]7th June 2013[/editline]
Licences and copyright notices aren't needed to assert ownership of a work.
So I've got extremely simple Verlet integration in unity, it works great, but I can't get colliders to work. With trigger colliders and Kinematic rigidbodies, I can sense when I hit something, but I'm not sure exactly what to do after that. Code attachedL
[code]#pragma strict
var targets : GameObject[];
private var lastX : float;
private var lastY : float;
var velX : float;
var velY : float;
var gravity : float;
var restDistance : float;
var tearDistance : float;
var stiffness : float;
var thisMass : float;
private var guiVar : float;
function Start () {
}
function FixedUpdate () {
velX = transform.position.x - lastX;
velY = transform.position.y - lastY;
lastX = transform.position.x;
lastY = transform.position.y;
transform.position.x = transform.position.x + velX;
transform.position.y = transform.position.y + velY+gravity;
SolveLink();
guiVar = velX;
}
function SolveLink () {
for(var point : GameObject in targets){
//We calculate the difference in position and distance
var diffX = transform.position.x - point.transform.position.x;
var diffY = transform.position.y - point.transform.position.y;
var d = Mathf.Sqrt(diffX*diffX+diffY*diffY);
//we get our distance scalar
var difference = (restDistance-d)/d;
//Translation of our point
var translateX = diffX * 0.5 * difference;
var translateY = diffY * 0.5 * difference;
transform.position.x += translateX;
transform.position.y += translateY;
Debug.DrawLine (transform.position,point.transform.position,Color.cyan);
}
}
function getMass (){return thisMass;}
function OnGUI(){
GUI.Box(Rect(0,0,100,20),"VelX: "+guiVar);
}
function OnTriggerStay(){
print ("collided");
}[/code]
Let's assume that I serialized something and it's saved in a file.
Then I'm opening it in hex-editor and I corrupt the file by writing random crap.
What is the best way to detect that this file was corrupted when I load it? Is there a way without using exceptions?
[code]
private void button1_Click(object sender, EventArgs e)
{
string name = "Quentin";
int x = 3;
x = x * 17;
double d = Math.PI / 2;
MessageBox.Show "name is " + name
+ "\nx is " + x
+ "\nd is " + d;
[/code]
I can't figure out what is wrong. The IDE is complaining about MesssageBox.Show saying "Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statement".
Same with + "\nd is " + d;.
It's also complaining that it wants a ; in "name is " + name
I'm following a book so I must figure out what I'm doing wrong else I don't feel like I can progress further. :v:
[QUOTE=suXin;40935026]Let's assume that I serialized something and it's saved in a file.
Then I'm opening it in hex-editor and I corrupt the file by writing random crap.
What is the best way to detect that this file was corrupted when I load it? Is there a way without using exceptions?[/QUOTE]
Md5 hash check it after saving and before loading?
[editline]7th June 2013[/editline]
[QUOTE=PredGD;40935169][code]
private void button1_Click(object sender, EventArgs e)
{
string name = "Quentin";
int x = 3;
x = x * 17;
double d = Math.PI / 2;
MessageBox.Show "name is " + name
+ "\nx is " + x
+ "\nd is " + d;
[/code]
I can't figure out what is wrong. The IDE is complaining about MesssageBox.Show saying "Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statement".
Same with + "\nd is " + d;.
It's also complaining that it wants a ; in "name is " + name
I'm following a book so I must figure out what I'm doing wrong else I don't feel like I can progress further. :v:[/QUOTE]
[code]
private void button1_Click(object sender, EventArgs e)
{
string name = "Quentin";
int x = 3;
x = x * 17;
double d = Math.PI / 2;
MessageBox.Show("name is " + name
+ "\nx is " + x
+ "\nd is " + d);
[/code]
?
Thanks, got it sorted out now. I had to flip the page back and check if the book wanted me to type that in the first place, which it of course wanted me to. :v: I should read this more thoroughly.
[QUOTE=PredGD;40935227]Thanks, got it sorted out now. I had to flip the page back and check if the book wanted me to type that in the first place, which it of course wanted me to. :v: I should read this more thoroughly.[/QUOTE]
Or learn what it is you're doing instead of blindly typing it out?
It's a method call, method calls ALWAYS have parentheses.
Getting something to work isn't nearly as important as knowing what the things you're typing do and mean. Does the book not have a step-through of the code after every example to show you what each line of code does?
[QUOTE=mobrockers;40935187]Md5 hash check it after saving and before loading?[/QUOTE]
I thought about that, but here comes the question 'where to keep that hash?'.
If I'd put it at the beginning or end of file for ease sake, that hash won't be the actual hash of this file.
Or I could check the hash of eveything what's located before the hash at the end of file?
I've barely scratched the surface of the book and I'm still learning, so right now I'm just taking notes and writing what it wants me to do while learning what all of these things do.
[QUOTE=suXin;40935251]I thought about that, but here comes the question 'where to keep that hash?'.
If I'd put it at the beginning or end of file for ease sake, that hash won't be the actual hash of this file.
Or I could check the hash of eveything what's located before the hash at the end of file?[/QUOTE]
Keep the hash in a separate file?
[editline]7th June 2013[/editline]
[QUOTE=PredGD;40935254]I've barely scratched the surface of the book and I'm still learning, so right now I'm just taking notes and writing what it wants me to do while learning what all of these things do.[/QUOTE]
I'm just saying, learn what a method etc looks like and you'll be able to easily spot this yourself. In a couple exercises you wouldn't even have to precisely read the book because you'd know what they meant. If you knew what a method call looked like you wouldn't have looked at the parentheses in the book but you'd still have known they'd have to be there.
[QUOTE=mobrockers;40935247]Or learn what it is you're doing instead of blindly typing it out?
It's a method call, method calls ALWAYS have parentheses.
Getting something to work isn't nearly as important as knowing what the things you're typing do and mean. Does the book not have a step-through of the code after every example to show you what each line of code does?[/QUOTE]
It totally does though :v:
[t]http://puu.sh/3aimU.png[/t]
I'm absolutely sure MessageBox.Show was explained earlier on.
[QUOTE=mobrockers;40935261]Keep the hash in a separate file?[/QUOTE]
Nah, want to keep it more compact. Maybe I'll try some advanced file seeking later.
The usual approach is to replace the hash with all 0's or something before calculating it.
Bit of a stupid question, haven't worked with C in a while:
[code] for(int w=0; w<n; w++) {
for(int h=0; h<n; h++) {
if(grid[w][h] == 'p') {
princess_column = w;
princess_row = h;
// I want to break out of every loop when this happens.
}
}
}[/code]
After the row and column is found, I want to break out of all the loops and go on the the code after the last brace.
goto
I thought using goto was bad practice though?
Sorry, you need to Log In to post a reply to this thread.