• What do you need help with? Version 5
    5,752 replies, posted
on to problem 4 then, since i don't want to keep bothering people since i don't understand any of the code for primality
[QUOTE=st_nick5;39369997]Thought I was, in the draw() function, I have vertices[indices[i]-1].x, etc. Wouldn't that do it?[/QUOTE] True, I was expecting you'd do it at load time instead. You're using GL_QUADS in your draw function but loading a triangle list.
[QUOTE=bean_xp;39370169]True, I was expecting you'd do it at load time instead. You're using GL_QUADS in your draw function but loading a triangle list.[/QUOTE] Bugger. Didn't see that. I changed it to GL_TRIANGLES, seems to be working now. Thanks.
So I have a dreamspark account and want to download Visual Studio 2012 as I started learning C++ and F# at Uni. but dreamspark is a clusterfuck of like a million different versions of things. No idea which one I have to download.
[QUOTE=alien_guy;39370835]So I have a dreamspark account and want to download Visual Studio 2012 as I started learning C++ and F# at Uni. but dreamspark is a clusterfuck of like a million different versions of things. No idea which one I have to download.[/QUOTE] What version of dreamspark do you have? Boh should have Visual Studio Professional, but if you have dreamspark pro you might also get Visual Studio Ultimate
[QUOTE=Meatpuppet;39370081]on to problem 4 then, since i don't want to keep bothering people since i don't understand any of the code for primality[/QUOTE] Problem 3 in Project Euler? You don't even need to test for primality: [cpp]#include <stdio.h> int main() { long n = 600851475143; int i = 2; while (n != 1) { if (n % i == 0) { n /= i; } else { i++; } } printf("%d\n", i); return 0; }[/cpp]
Could anybody explain how I would go about debugging this? I'm using pygame and the Draw method isn't clearing the area the sprite was before drawing it in a new position. [url]https://github.com/adjohu/gamething/blob/master/view.py[/url] [b]Edit: Don't worry - fixed. I wasn't filling the background on every tick.[/b]
[QUOTE=ArgvCompany;39371122]Problem 3 in Project Euler? You don't even need to test for primality: [cpp]#include <stdio.h> int main() { long n = 600851475143; int i = 2; while (n != 1) { if (n % i == 0) { n /= i; } else { i++; } } printf("%d\n", i); return 0; }[/cpp][/QUOTE]but it says prime factors
For some reason [code]XmlElement.Load(file);[/code] doesn't work on Mono, any ideas on how to fix/find another way to do this? [editline]27th January 2013[/editline] I read about using gmcs instead of the default compiler when using MonoDevelop, but I can't seem to find the setting.
[QUOTE=Meatpuppet;39371615]but it says prime factors[/QUOTE] You won't have any non-prime factors, because you've already divided the prime factors of those out of the number.
[QUOTE=ArgvCompany;39371896]You won't have any non-prime factors, because you've already divided the prime factors of those out of the number.[/QUOTE] how?
Can I ask questions about Unity in here?
[QUOTE=Pelf;39372104]Can I ask questions about Unity in here?[/QUOTE] Yes
[QUOTE=Pelf;39372104]Can I ask questions about Unity in here?[/QUOTE] no this is assembly only thread
This is my scene: [t]https://dl.dropbox.com/u/13781308/helep.png[/t] This is a placeholder menu for my game. When the player clicks on certain buttons in the middle column, I want the camera to move left/right over the course of a second or two to show a new menu (kind of like in Kerbal Space Program). This is the script that I have on the camera to detect mouse clicks: [CODE]using UnityEngine; using System.Collections; public class MainMenuControl : MonoBehaviour { void Update() { if (Input.GetKeyDown(KeyCode.Mouse0)) { // Declaring rays Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000.0f)) { // Check what was clicked and provide appropriate response switch (hit.collider.name) { case "Main SP": Debug.Log("Main SP"); break; case "Main MP": Debug.Log("Main MP"); break; case "Main Options": Debug.Log("Main Options"); break; case "Main Exit": Application.Quit(); break; case "Main Title": Application.LoadLevel("ZeroGTest"); break; default: break; } } } } } [/CODE] Everything there works but I can't get the camera to move over time. I've tried using code like in the example [URL="http://docs.unity3d.com/Documentation/ScriptReference/Mathf.MoveTowardsAngle.html"]here[/URL] (I was trying to rotate the camera at first), I've tried putting the code in the switches and in separate methods, but the most I could get was either having the camera move instantly (not gradually over the course of a second or two) or it would move a portion of the distance in one frame then stop. How can I get the camera to move left/right over time?
[QUOTE=evil-tedoz;39338063]How should I structure a mesh class if I want it the most VBO friendly possible ?[/QUOTE] Anybody ? I'm using C++/OpenGL. That would be very helpful, thanks.
[QUOTE=evil-tedoz;39373797]Anybody ? I'm using C++/OpenGL. That would be very helpful, thanks.[/QUOTE] This is my thing in D: [url]http://pastebin.com/0jSw9M7v[/url]
[QUOTE=Pelf;39372360] Everything there works but I can't get the camera to move over time. I've tried using code like in the example [URL="http://docs.unity3d.com/Documentation/ScriptReference/Mathf.MoveTowardsAngle.html"]here[/URL] (I was trying to rotate the camera at first), I've tried putting the code in the switches and in separate methods, but the most I could get was either having the camera move instantly (not gradually over the course of a second or two) or it would move a portion of the distance in one frame then stop. How can I get the camera to move left/right over time?[/QUOTE] To make the camera move without jumping in unity use [code]Camera.main.gameObject.transform.Translate(Vector3(x,y,z))[/code] [url]http://docs.unity3d.com/Documentation/ScriptReference/Transform.Translate.html[/url] This will move the camera in the direction you specify
[QUOTE=Meatpuppet;39372022]how?[/QUOTE] Because the prime factors of the non-prime factors come before them in the loop. For example, let's say I've got 36. It has, among others, non-prime factors 9 and 4. If you run the program on 36, it will divide out 2 two times before it gets to 4, and then it has effectively divided 4 from the number. The biggest factor you will get from 36 is 3 (which is prime).
Just a quicky, which is faster for storing a large-ish 2D array of floats, where for instance foo [x][y] represents a coordinate (x,y) associated with a 'weight' (float)....the data is read very often, but written to only occasionally and in segments (32x32) blocks at a time. I'm using a dictionary<coord, float> with a good (space | collison) hash function for the coordinates, where each coord is a struct. the array is NOT-sparse...the key/index is used when the values are updated in distance calculations with a taxi-cab heuristic before Euclidean metric which are passed to another function.
[QUOTE=Spero78;39375215]To make the camera move without jumping in unity use [code]Camera.main.gameObject.transform.Translate(Vector3(x,y,z))[/code] [URL]http://docs.unity3d.com/Documentation/ScriptReference/Transform.Translate.html[/URL] This will move the camera in the direction you specify[/QUOTE] I tried this but it moves the camera instantly. In the cases that require the camera to move I now have this: [code]// Move camera to right menu case "Main SP": moveDistance = 50; MoveCamera(); Debug.Log("Main SP"); break; // Move camera to left menu case "Main MP": moveDistance = -50; MoveCamera(); Debug.Log("Main MP"); break; [/code] and this: [code]void MoveCamera() { transform.Translate(moveDistance, 0, 0); }[/code] But it just moves the camera over one frame, not slowly over time. [editline]edit[/editline] I just tried putting Time.deltaTime in with the movement like so: [CODE]transform.Translate(moveDistance * Time.deltaTime, 0, 0);[/CODE] But that only moves the camera the distance it would move in one frame so it only moves ~1 meter or so left or right when I click on it. Is there some way to have that repeat until it moves the required distance? [I]Edit:[/I] Ok, I figured out coroutines and got it to start moving properly. I'll figure it out how to make it stop moving on my own. Thanks.
Game loop + velocity?
Hey guys, is anyone prepared to explain the Runge-Kutta method of integration to me? I don't quite get how variables change and affect one-another without the previous variables being stored.
~snip
Anyone can give help how to use BackgroundWorker 'properly' in Windows Forms with C#? In form1 class [code] WorkerObject workerObject; Thread processing; private void button1_Click(object sender, EventArgs e) { workerObject = new WorkerObject(); backgroundWorker1.RunWorkerAsync(); } private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { int toProcess = workerObject.stuffToProcess; int percent = 0; processing = new Thread(new ThreadStart(workerObject.DoStuff)); processing.Start(); backgroundWorker1.ReportProgress(percent); while (processing.IsAlive) { percent = (int)Math.Ceiling((double)workerObject.stuffProcessed / (double)toProcess); backgroundWorker1.ReportProgress(percent); Thread.Sleep(toProc*100); } backgroundWorker1.ReportProgress(percent); MessageBox.Show("Work done"); } private void backgroundWorker1_OnProgressChanged(ProgressChangedEventArgs e) { progressBar1.Value = e.ProgressPercentage; }[/code] [code] class WorkerObject { public int stuffToProcess; public int stuffProcessed = 0; public WorkerObject() { stuffToProcess = 60; } public void DoStuff() { while ( stuffToProcess > stuffProcessed ) { stuffProcessed++; Thread.Sleep(1000); } } }[/code] May look weird (this is just base code from my program) but this actually works though the progressBar1 isn't updating. And it doesn't look to me that I'm doing it correctly. As if I have a thread withing a thread.
[QUOTE=Nicht Du;39378046]My question to you is, do you know of any better way to check for collisions? I think I've seen someone who had a few thousand particles interacting with each other here on facepunch not long ago. Thanks in advance :)[/QUOTE]One thing that would speed it up is if you are simply comparing distances, to square the other side rather than using squareroot on the other. A single multiplication is far faster than the square root function. Also, this can be simplified: [code] double distance=Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));[/code] to [code]int dx = x2-x1; int dy = y2-y1; double distance = Math.sqrt(dx*dx+dy*dy);[/code]
This code seems weird: [cpp]bool Text::operator== (Text t) { bool boolean = (text.getString() == t.getString()) ? true : false; return boolean; }[/cpp] I feel like I don't need the variable. Can I simplify this?
[cpp]bool Text::operator== (Text t) { return (text.getString() == t.getString()); }[/cpp]
thanks!
I'm starting to lean c++ after learning java and I'm have a but of trouble. (I feel like such a noob D=) So lets say I have class A, see example [code] class A{ public A next; public A(A link){ this.link = link; } } [/code] How would I go about doing next = next.next in c++?
Sorry, you need to Log In to post a reply to this thread.