• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=Armandur;36679388]What is the proper syntax for outputting to a pointer fstream file in an std::list<std::fstream*>? This doesn't work. [cpp] comics.front() << html[0] << c.getYear() << " - " << c.getMonth() << html[1] << c.getYear() << " - " << c.getMonth() << html[2] << c.getMonth() << html[3] << c.getDay() << html[4] << c.getDay() << html[5] << std::endl; comics.front().close(); [/cpp][/QUOTE] [cpp] (*comics.front()) << html[0] << c.getYear() << " - " << c.getMonth() << html[1] << c.getYear() << " - " << c.getMonth() << html[2] << c.getMonth() << html[3] << c.getDay() << html[4] << c.getDay() << html[5] << std::endl; comics.front()->close(); [/cpp]
I can't get my program to create and write a file with fstream (Does it have to be .txt or can I use .html?). Even this doesn't work: [cpp] #include <iostream> #include <fstream> int main() { std::ofstream temp("2006 - Dilbert - 07.txt", std::ofstream::in | std::ofstream::out); temp.close(); std::cin.get(); return 0; } [/cpp]
What do you mean it doesn't work?
[QUOTE=Armandur;36680640]I can't get my program to create and write a file with fstream (Does it have to be .txt or can I use .html?). Even this doesn't work: [cpp] #include <iostream> #include <fstream> int main() { std::ofstream temp("2006 - Dilbert - 07.txt", std::ofstream::in | std::ofstream::out); temp.close(); std::cin.get(); return 0; } [/cpp][/QUOTE] Why are you using both the in and the out flags on an [b]o[/b]ut[b]f[/b]ile[b]stream[/b]?
Does Love 0.8.0 have any way of setting the volume for individual channels(i.e Left, right)? [editline]9th July 2012[/editline] Im trying to implement 2d sound with love(Ideally I would like to control individual channels) so far I have: [lua] function toRad(n) return n * 0.0174532925 end function love.load() love.graphics.setBackgroundColor( 255, 255, 255, 255 ) image = love.graphics.newImage("Speaker.png") music = love.audio.newSource("Reunited.mp3") music:setLooping( true ) music:setDirection( 0, 1, 0 ) music:setPosition( 300, 300, 0 ) music:setDistance( 1, 200 ) music:play() end function love.update(dt) x = love.mouse.getX() - 300 y = love.mouse.getY() - 300 love.audio.setPosition( x, y, 0 ) end function love.draw() love.graphics.draw( image, 300, 300, toRad(90), 1, 1, 16, 16, 0, 0 ) love.graphics.setColor(0, 0, 0, 255) love.graphics.print("Song: Reunited by Incomptech.com", 5, 5) love.graphics.print(music:getVolume(), 5, 50) end[/lua] But nothing happens, I think the problem is I dont know what the ref is meant to be in: Source:setDistance( ref, max )
[QUOTE=dajoh;36677246][url=http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx]GetWindowRect[/url][/QUOTE] I'm talking about the client rect rather than the window rect.
I just can't wrap my head around how to respond to collisions. I'm able to detect AABB collisions, but I have no idea on how to do something like push the player out of the other object.
Oh for fu- A little ActionScript 3 problem. [code]package { //import flash.utils.ByteArray; import net.flashpunk.Entity; import net.flashpunk.graphics.Image; import orgplay.OrgPlayer; public class titleEvents extends Entity { [Embed("../lib/NES_Pinball.org", mimeType="application/octet-stream")] private static const PINBALL_ORG:Class; private var orgPlayer:OrgPlayer; [Embed(source = 'img/titlelogo.GIF')] private const LOGO:Class; // Remove above line when through with demonstrating ORG playback. public function titleEvents(){ graphic = new Image(LOGO); orgPlayer = new OrgPlayer(PINBALL_ORG); orgPlayer.play(); } } }[/code] [highlight]Line 24: col: 30 Error: Implicit coercion of a value of type Class to an unrelated type flash.utils:ByteArray.[/highlight] The problem lies in the line: [code]orgPlayer = new OrgPlayer(PINBALL_ORG);[/code] to be short. Ain't got a clue on where to start even fixing this.
[QUOTE=Stonecycle;36697013]Ain't got a clue on where to start even fixing this.[/QUOTE] Never used AS, but I found something that might help you. Apparently the Embed statement thingie creates a new class instead of an object instance, which you need to instantianate to get the actual resource. For example [csharp] [Embed("../lib/NES_Pinball.org", mimeType="application/octet-stream")] private static const PinballOrg:Class; // Later orgPlayer = new OrgPlayer(new PinballOrg()); // or if that doesn't work var org:ByteArray = new PinballOrg() as ByteArray; orgPlayer = new OrgPlayer(org); [/csharp] Same thing for LOGO I guess. Google "actionscript embed bytearray"
[QUOTE=raBBish;36697140]Never used AS, but I found something that might help you. Apparently the Embed statement thingie creates a new class instead of an object instance, which you need to instantianate to get the actual resource. For example [csharp] [Embed("../lib/NES_Pinball.org", mimeType="application/octet-stream")] private static const PinballOrg:Class; // Later orgPlayer = new OrgPlayer(new PinballOrg()); // or if that doesn't work var org:ByteArray = new PinballOrg() as ByteArray; orgPlayer = new OrgPlayer(org); [/csharp] Same thing for LOGO I guess. Google "actionscript embed bytearray"[/QUOTE] First solution did it. Thank you very, [b]very[/b] much.
What'd be the best method of storing bullets? I originally figured that I could store them in a list, but then I noticed that there was surely a better and more efficient way to do it.
[QUOTE=Mr. Smartass;36699854]What'd be the best method of storing bullets?[/QUOTE] Something with fast insertion/deletion but slower random array access.
I have a pretty general question about cross-platform development that I can't seem to find any straight-forward answers on. A 64bit Windows machine can run 32bit Window applications. Usually. This is nice and easy. On Linux, from my understanding (and I'm looking for someone to tell me I'm correct or horribly wrong here), there are different distros and there are different architectures. Whether or not an application RUNS depends on if it was built for that architecture. Whether or not it installs as a package depends on if it was packaged for that distro. If I just gave someone an executable, they can run it so long as they have the correct architecture. Is this correct? Should I target i386 for 32bit and x86_64 for 64bit? Can someone explain to me how this works on a Mac?
[QUOTE=jalb;36700639]Should I target i386 for 32bit and x86_64 for 64bit?[/QUOTE] Yes. Don't make the same mistake I did and assume some kind of backwards compatibility.
If I were to make a very secure c# application that uses mysql, what kind of things would I need to practice? How would I store the connection string (I think people can decompile)? I already know most of the sql stuff, but not so much in windows environment programs.
[QUOTE=Floatation;36706986]If I were to make a very secure c# application that uses mysql, what kind of things would I need to practice? How would I store the connection string (I think people can decompile)? I already know most of the sql stuff, but not so much in windows environment programs.[/QUOTE] Do stuff server-side.
[QUOTE=Floatation;36706986]If I were to make a very secure c# application that uses mysql, what kind of things would I need to practice? How would I store the connection string (I think people can decompile)? I already know most of the sql stuff, but not so much in windows environment programs.[/QUOTE] What Darkwater means is that the database is never exposed to the client, there's some kind of middleware application that talks to the client, checks the data and then runs database operations.
[QUOTE=Floatation;36706986]If I were to make a very secure c# application that uses mysql, what kind of things would I need to practice? How would I store the connection string (I think people can decompile)? I already know most of the sql stuff, but not so much in windows environment programs.[/QUOTE] I don't think that's possible. What I do is I normally make an ASP.NET script that is fetching the data into an XML document (server-side) and then using a XML-parser in C# to retrieve the data. I think that's the safest way.
[QUOTE=jalb;36700639]On Linux, from my understanding (and I'm looking for someone to tell me I'm correct or horribly wrong here), there are different distros and there are different architectures. Whether or not an application RUNS depends on if it was built for that architecture. Whether or not it installs as a package depends on if it was packaged for that distro. If I just gave someone an executable, they can run it so long as they have the correct architecture. Is this correct?[/QUOTE] x86_64 Linux can run i386 programs, just like in Windows. The complication is that most programs depend on a few libraries, and 32-bit executables need 32-bit libraries, and a 64-bit system might not have 32-bit libraries installed. 64-bit Windows includes 32-bit versions of all the system libraries because backward-compatibility with 32-bit apps is essential there, but on Linux, programs are typically just recompiled as native 64-bit binaries, so the 32-bit compatibility is less essential. Any major distro should have some way to get 32-bit versions of the most common libraries installed, but they might not be there by default, and the packaging that makes them available tends to be klugey — i.e. the package claims to be built for 64-bit so that the package manager will be willing to install it, even though it contains 32-bit binaries and puts them in odd places to avoid conflicts with the real 64-bit versions. You're better off building both 32-bit and 64-bit binaries, rather than building just a 32-bit binary and expecting 64-bit users to run it too. [QUOTE=jalb;36700639]Should I target i386 for 32bit and x86_64 for 64bit?[/QUOTE] If you're only talking about Intel/AMD-compatible processors, yes. But remember that there are other, unrelated architectures like like ARM (used by most mobile devices) and PPC (used by older Macs), which also have their own 32-bit and 64-bit flavors. If you want to support those architectures, you have to build separate binaries for them as well.
tryin to make a 2d array for a life form simulator. [code] float cell[20][20]={ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, }; // the block of numbers shows the starting position of everything- 0 means nothing is there, 1 means lifeform. Will eventally add mutations and numbers increasing past 1. [/code] Is there a better way to do this? My c++ compiler is yelling at me, feeding back "1>c:\users\maxwell\dropbox\universal calculator\life\life\main.cpp(27): error C2078: too many initializers" whenever I attempt to do this. Didn't do it when it was only a 10x10 grid.
If it's all zeros, why not just initialize it at runtime with a loop?
[QUOTE=krazipan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0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, }; // the block of numbers shows the starting position of everything- 0 means nothing is there, 1 means lifeform. Will eventally add mutations and numbers increasing past 1. [/code] Is there a better way to do this? My c++ compiler is yelling at me, feeding back "1>c:\users\maxwell\dropbox\universal calculator\life\life\main.cpp(27): error C2078: too many initializers" whenever I attempt to do this. Didn't do it when it was only a 10x10 grid.[/QUOTE] Sure. [cpp]float cell[20][20]; memset( cells, 0, sizeof( cells ) );[/cpp]
That's much more efficient than my suggestion of a loop, but initializing things with memset() has always bothered me a little. It's making a non-portable assumption that a certain value of a certain data type is physically represented by a certain bit pattern in RAM. (Yes, setting to zero is valid for floats with IEEE754, but even IEEE754 isn't universal.) However, krazipanda, why are you using floats when it sounds like the values will all be integers? If each distinct value has a specific meaning, I'd recommend using an enum as the type of your array.
[QUOTE=Overv;36712195]Sure. [cpp]float cell[20][20]; memset( cells, 0, sizeof( cells ) );[/cpp][/QUOTE] Would I use it the exact same way, or would anything be different?
I would like to make a textbox class for my XNA game. I am struggling on the "focus" aspect, so that when you type it knows which textbox to send the letters to. In windows forms, if you have 2 text boxes, say, then click inside one, it will highlight/focus and you can type in it. Click on the other and the other will defocus, how does .NET do this object interaction? It doesn't store a list of text boxes, and there is no textbox manager or something to say which has focus and which does not. Seemingly trivial question but I can't seem to find a neat solution, any ideas? Cheers
I'm trying to use stringstreams for getting ints into a string. I do it like this: [cpp] DilbertImage::DilbertImage(int d) { cal.setDate(d); int year, month, date; year = cal.getYear(); month = cal.getMonth(); date = cal.getNumDate(); std::stringstream ss; ss << year << "/"; if(month < 10) { ss << 0; } ss << month << "/" << "Dilbert - " << cal.getNumDate() << ".gif"; filePath = ss.str(); ss.str(""); ss.clear(); ss << startUrl << date << endUrl; url = ss.str(); std::cout << url << '\t' << filePath << std::endl; } [/cpp] [cpp] std::string const DilbertImage::startUrl = "http://tjanster.idg.se/dilbertimages/dil"; std::string const DilbertImage::endUrl = ".gif"; [/cpp] I expect to get two nice strings that look like this: [code] url: http://tjanster.idg.se/dilbertimages/dil20060720.gif filePath: /2006/07/Dilbert - 20060720.gif [/code] But instead when I put the ints in the stringstream they somehow endup getting spaces (or some other blank character inserted in the middle of them) They end up looking like this: [code] url: http://tjanster.idg.se/dilbertimages/dil20*060*720.gif filepath: /2*006/07/Dilbert - 20*060*720.gif [/code] I've been trying to get this to work all night now, why is this happening :( EDIT: Now when I pasted it, the spaces show up as * symbols... Here is the whole project: [url]http://pastebin.com/20KF2dNL[/url]
[QUOTE=krazipanda;36712739]Would I use it the exact same way, or would anything be different?[/QUOTE] If you want to use ints? Exact same.
[QUOTE=Overv;36713295]If you want to use ints? Exact same.[/QUOTE] Wouldn't I have to use a float/double to make the compiler not yell at me for going over the allocated memory? [editline]10th July 2012[/editline] wait, can you have the datatype be a float for the array and then call out specific parts of it as ints? I'm not too confident on my knowledge of floats/doubles and ints.
[QUOTE=krazipanda;36713678]Wouldn't I have to use a float/double to make the compiler not yell at me for going over the allocated memory? [editline]10th July 2012[/editline] wait, can you have the datatype be a float for the array and then call out specific parts of it as ints? I'm not too confident on my knowledge of floats/doubles and ints.[/QUOTE] If you mean a mixed-type array, that is possible, if you want to get dirty.
[QUOTE=Wyzard;36712060]informative post[/QUOTE] Thanks for your explanation, it definitely cleared things up for me. Been trying to find someone who could break that down for me just the way you did.
Sorry, you need to Log In to post a reply to this thread.