• What do you need help with? V4 (January 2012)
    966 replies, posted
[QUOTE=mechanarchy;34891593]It might be an idea to make a thread for this, I find myself asking similar questions a lot. But here's a few ideas that may be of help to you: Temperature converter (not just Fahrenheit\Celsius but also Kelvin, Rankine, anything else you can think of) Unit converter (eg metres to yards, decades to days, whatever) Basic calculator Caesar (letter-shift) cipher Other types of basic ciphers Numeric base converter (eg 10 in base 16 == 16 in base 10 == 20 in base 8 == 10000 in base 2)[/QUOTE] Thank you, those are wonderful ideas. =] I'll probably attempt to make some sort of cipher.
[QUOTE=swift and shift;34890565]the C# standard guarantees all variables are automatically initialized to default(T). default(int) is 0[/QUOTE] Fields are, local variables are not. int num; Console.Write(num); //Error, use of uninitialized variable. [QUOTE=marcin1337;34896068]Can someone give me pointers( not NULL ) on how to improve my GUI a bit ? [t]http://dl.dropbox.com/u/408914/Debug/facepunch.JPG[/t][/QUOTE] Call [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx"]Application.EnableVisualStyles[/URL](); Or just switch to wpf. Winforms are very ugly/slow.
I currently store maps in an image, and then depending on the color of each pixel on the image I add a tile. However I want to add border tiles and such, but i dont know how to do it. My current thought is to have a list of all possible tiles then do something along the lines of: for pixel x { for pixel y { check the surroundings of the current pixel for w = -1 < 1 { for z = -1 < 1 { depending on the surrounding of the current pixel take out elements from the list } } } }
How do I handle folder structures in Java? The help files I've found aren't very, well, helpful. I know I can pull from files directly but really I just want to organize the mess of extra weapons and things I'm putting into my game. Additionally, how does this work with inheritance, and extending classes across folders?
Hey guys, I have next to no programming ability at all. I dabbled in Lua and Love2D a little bit, and I've been working with a friend on a few game projects, and in the process picked up a miniscule amount of Java. I got my friend to try and teach me, and I just spent 10 minutes making a box travel in different directions before I got bored and quit. I have pitiful skill and grades in mathematics; I've repeated pre-algebra 3 times so far. I do, however, have a lot of experience in pixel art, texturing, effects, and creating visuals for games that look good and can be implemented easily. What I want to know is [b]what is the most piss easy and simple legitimate programming language? [/b] If it's Love2D then I'll go back to learning that. If it's Actionscript, I'll grab a copy of Flash and learn that. Also, the last thing I want is some candy-ass "Learn 2 make games free" GameMaker or Scratch BS. If you guys could help, that'd be very greatly appreciated.
Making Asteroids clone in XNA. I'm using Microsoft's Game State Management project to handle my main menu and gameplay. So far it's been well, but when I try to draw the ship it gets weird. It won't move forward for some reason Ship Input Code: [CODE] private void HandleInput() { input = Keyboard.GetState(); float x = position.X; float y = position.Y; Matrix m = Matrix.CreateRotationZ(rotation); if (input.IsKeyDown(Keys.Right)) rotation += turnFactor; else if (input.IsKeyDown(Keys.Left)) rotation -= turnFactor; else if (input.IsKeyDown(Keys.Up)) { x += m.M12 * directionFactor; y -= m.M11 * directionFactor; } else if (input.IsKeyDown(Keys.Down)) { x -= m.M12 * directionFactor; y += m.M11 * directionFactor; } position.X = x; position.Y = y; Console.WriteLine("Y: {0} ", y); Console.WriteLine("X: {0} ", x); }[/CODE] Position is a Vector2D. Draw code: [CODE]public void Draw(SpriteBatch sb) { Vector2 origin = new Vector2(ship.Width / 2, ship.Height); sb.Draw(ship, ship.Bounds, null, Color.White, rotation, origin, SpriteEffects.None, 0f); } [/CODE] It rotates around the top left corner of the window(when you press left or right obviously), which shouldn't happen due to me calling my reset method to move it towards the center of the screen: [CODE] public PlayerShip(Game game) { this.game = game; Viewport view = game.GraphicsDevice.Viewport; center = new Vector2(view.Width / 2, view.Height /2); Reset(center); } public void Reset(Vector2 position) { this.position = position; } [/CODE] Anyone know why it's not appearing in the center and why it's not moving up or down on the screen? When hooking the game up to a command window, the X and Y values appear to be getting updated but it's not showing on the screen.
[QUOTE=salmonmarine;34903641]before I got bored and quit.[/QUOTE] there's your problem, programming is all about motivating yourself
How do I call a method that has a "Random random" parameter? I don't know what to fill in. [csharp] static void Main(string[] args) { int x = 5; DoSomething(*Something here*, x); } static int DoSomething(Random random, int a) { } [/csharp]
Try [code] static void Main(string[] args) { Random rand = new Random(); int x = 5; DoSomething(rand, x); } static int DoSomething(Random random, int a) { } [/code]
I made a name generator that uses a few syllables (or snippets) to come up with a new name. My problem is that I don't know how to use the enum 'NameSyllables' like I use the list 'nameSyllables'. What do I do and how do I use the enum instead of the list? Or would it be best to use an array instead? [csharp] public enum NameSyllables { Kan, As, Les, Fay, Kolt, Mes, Ert, Yui, Ali, Tiu } static void Main(string[] args) { Console.Title = "Name Generator"; Random random = new Random(); List<string> nameSyllables = new List<string>(); nameSyllables.Add("kan"); nameSyllables.Add("as"); nameSyllables.Add("les"); nameSyllables.Add("fay"); nameSyllables.Add("kolt"); nameSyllables.Add("mes"); nameSyllables.Add("ert"); nameSyllables.Add("yui"); nameSyllables.Add("ali"); nameSyllables.Add("tiu"); Console.WriteLine(@"Welcome to the name generator! Press Enter to generate a new name."); generate: int x = random.Next(10); int y = random.Next(10); while (x == y) { x = random.Next(10); y = random.Next(10); } Console.ReadLine(); Console.WriteLine(nameSyllables[x] + nameSyllables[y]); goto generate; } [/csharp]
Okay migrating [url=www.facepunch.com/threads/1167060]my thread's question[/url] here for better coverage. [quote]Alright, I fucked up this semester and just durdled around in my CS class so now I have no idea what the fuck I am doing. I'd like to at least manage a tangentially passing grade and just take the course over next year in college and to do that I need to actually turn in some homework. For all you Java whiz kids out there, help a newbie out, I'd really appreciate it. This week's homework is question 1 from [url=http://apcentral.collegeboard.com/apc/public/repository/ap09_frq_computer_science_a.pdf]this packet[/url]. Basic pointers on what exactly I'm supposed to do would be the best.[/quote]
I've heard the New Boston's shit but I'm in 80 tutorials and feel somewhat competent. Should I just stop learning? Should I keep going on? Should I finish then go read a book about it? What do you guys recommend? [editline]28th February 2012[/editline] I'm learning Java btw.
-snip- figured it all out
I thought I had vectors figured out, but turns out I'm wrong. How is this not working? [cpp] #include <vector> #include <string> #include <dirent.h> .. class specific code, unrelated .. std::vector< std::string > *Directory::Read() { std::vector< std::string > *directory_contents(); std::vector< std::string >::iterator *it; it = directory_contents->begin(); // Error: request for member 'begin' struct dirent *pent; while( (pent=readdir(this->dir) ) ) // this->dir is a string { std::string dirname = std::string( pent->d_name ); directory_contents->push_back( dirname ) // Error: request for member 'push_back' } } [/cpp]
[QUOTE=T3hGamerDK;34924872]I thought I had vectors figured out, but turns out I'm wrong. How is this not working? [cpp] #include <vector> #include <string> #include <dirent.h> .. class specific code, unrelated .. std::vector< std::string > *Directory::Read() { std::vector< std::string > *directory_contents(); std::vector< std::string >::iterator *it; it = directory_contents->begin(); // Error: request for member 'begin' struct dirent *pent; while( (pent=readdir(this->dir) ) ) // this->dir is a string { std::string dirname = std::string( pent->d_name ); directory_contents->push_back( dirname ) // Error: request for member 'push_back' } } [/cpp][/QUOTE] [code] std::vector< std::string > *directory_contents(); [/code] you're saying "directory_contents" is a function taking zero arguments and returning std::vector<std::string>* remove the parentheses. [editline]29th February 2012[/editline] for an actual explanation of this, it's because there's ambiguity between creating an object by calling a constructor with no parameters and defining a function. [cpp]SomeClass test; // this is an object SomeClass test2 = SomeClass(); // this is an object explicitly calling the constructor with no args SomeClass test3 = SomeClass(5); // This is making an object with constructor taking one int arg SomeClass test3a(5); // However, trying to do that without any args is ambiguous SomeClass test4(); // wrong -- could be a function definition OR an object creation! so don't do it and avoid the trouble.[/cpp]
[QUOTE=mechanarchy;34924911][code] std::vector< std::string > *directory_contents(); [/code] you're saying "directory_contents" is a function taking zero arguments and returning std::vector<std::string>* remove the parentheses. [editline]29th February 2012[/editline] for an actual explanation of this, it's because there's ambiguity between creating an object by calling a constructor with no parameters and defining a function. [cpp]SomeClass test; // this is an object SomeClass test2 = SomeClass(); // this is an object explicitly calling the constructor with no args SomeClass test3 = SomeClass(5); // This is making an object with constructor taking one int arg SomeClass test3a(5); // However, trying to do that without any args is ambiguous SomeClass test4(); // wrong -- could be a function definition OR an object creation! so don't do it and avoid the trouble.[/cpp][/QUOTE] Oh wow, I really thought I had checked everything! Thanks a ton! :D
Also, you're calling directory_contents->begin() when directory_contents is an uninitialized pointer.
[QUOTE=Wyzard;34925507]Also, you're calling directory_contents->begin() when directory_contents is an uninitialized pointer.[/QUOTE] I think that's related to his thinking that dictionary_contents(); was creating the object.
[QUOTE=KStyleAzure;34922197]Okay migrating [url=www.facepunch.com/threads/1167060]my thread's question[/url] here for better coverage.[/QUOTE] a. Make a int array to hold all the values that the cube returns. Make a for loop that lasts while it's under numTosses. Each time you toss the cube, keep a number of it in the array. For example, [csharp] public static int[] getCubeTosses(NumberCube cube, int numTosses) { int[] values = new int[numTosses]; int tossed; for(int i = 0; i < numTosses; i++) { tossed = cube.toss(); values[i] = tossed; } return values; } [/csharp] b.For loop again. loop through each index, tracking which index you're checking has the cube run, and which index in the array currently has the largest run(set it to -1 at first). You can use the continue keyword to skip through 1 iteration of a loop, or do something like values[i++] to skip over an index if you know it's not a run. [editline]29th February 2012[/editline] [QUOTE=Zally13;34922528]I've heard the New Boston's shit but I'm in 80 tutorials and feel somewhat competent. Should I just stop learning? Should I keep going on? Should I finish then go read a book about it? What do you guys recommend? [editline]28th February 2012[/editline] I'm learning Java btw.[/QUOTE] If you're learning go ahead. I personally didn't learn much at all from him when I tried watching his vids last summer, but since I'm taking an APCS class I didn't really need his vids.
Yeah I feel like I get what he's saying. I always take a few then think about it and how I'd implement it myself.
Could anyone give me an example how to build a dynamic meshes in Source Engine? Simple cube for example.
How do I do multithreading in C++(Newbie here)? I've done a lot of googling, and the only results I got were either horrifically complex and specific, and/or don't say what anything actually does and how to use them. Or if there is some way around it, I basically want to run a loop of code while a form is open at the same time, and the form was built in VS2010's designer.
How do I implement STL-like containers in C++? I want to make a new container that would be fully compatible with STL algorithms and have proper iterators. Has anyone here ever done that or is there a good guide somewhere?
[QUOTE=Nicolas;34935127]Could anyone give me an example how to build a dynamic meshes in Source Engine? Simple cube for example.[/QUOTE] Check out IMatRenderContext::GetDynamicMesh and CMeshBuilder.
Been messing around with GWEN as of lately but I can't seem to work this out. TestApp.cpp [CODE]#include "TestApp.h" GWEN_CONTROL_CONSTRUCTOR( TestApp ) { Dock( Pos::Fill ); CreateButton(); } void TestApp::CreateButton() { Controls::Button* pButtonA = new Controls::Button( this ); pButtonA->SetText( L"Start" ); pButtonA->onPress.Add( this, &TestApp::onButtonA ); pButtonA->SetPos(75, 175); } void TestApp::onButtonA() { pButtonA->SetText("lol"); }[/CODE] TestApp.h [CODE] #pragma once #include "Gwen/Gwen.h" #include "Gwen/Controls.h" #include "Gwen/Controls/Layout/Position.h" #include "Gwen/Controls/WindowControl.h" using namespace Gwen; /* The base panel */ class TestApp : public Controls::Base { GWEN_CONTROL( TestApp, Controls::Base ); public: void onButtonA(); void CreateButton(); };[/CODE] You can see in onButtonA() I am trying to set the text of pButtonA from CreateButton(), although I am getting "identifier pButtonA is undefned"
Sorry, you need to Log In to post a reply to this thread.