• Content count

  • Joined

  • Last visited

Community Reputation

232 Neutral

About MrAccident

  • Rank
  1. Jumping problems in C++

    Quote:Original post by ExcessNeo Mr. Accident Acceleration is constant yes being -9.81m/s/s however you can't just decide to end acceleration mid-air until you have reached terminal velocity, rip-off's example is a bit strange though having another look. But either way, gravitational acceleration should be subtracted from velocity, not the player's acceleration. If you subtract 9.81m/s^2 from the player's acceleration every frame, it is no longer an acceleration constant, but a jerk constant. Not counting air resistance, gravitation produces a constant acceleration, so the player's acceleration should not change unless another force acts upon them (for example, the ground). For simple jumping physics, air resistance isn't going to be a significant factor. But if you did want to add it to your model, you wouldn't do it by subtracting g from the object's acceleration every frame; for a decent approximation you could introduce an opposing force that scales linearly with the velocity of the object, and just add that to the gravitational acceleration vector to determine the object's acceleration at any given time.
  2. Jumping problems in C++

    It sounds like what you've been doing is just trying to "code as you go," which is definitely going to be a confusing and frustrating experience if you don't already have a good idea of how your system is going to work. It's always a good idea to clearly think out your approach and create a design before you start writing code. rip-off made a very good suggestion when he said you should decouple movement from input. What he meant (and illustrated with his code sample) is that you should give the player object physical properties like velocity and acceleration, instead of just directly changing the position of the player whenever the movement keys are pressed. Then, each frame you can add the player's velocity to their current position to make them move. Also each frame, subtract your gravitational acceleration constant from their upward velocity (unless they're already on the ground). The movement keys can then work by changing the player's velocity: if the left or right keys are pressed, the player should have a corresponding negative or positive X velocity. When the spacebar is pressed, you can just give the player an initial upward velocity, and your gravitational acceleration will take care of the rest. Adjusting the initial jump velocity will give you different jumping heights.
  3. Jumping problems in C++

    So, what exactly is the problem you're having? Code snippets alone in this case aren't very enlightening: it would help if you'd explain your reasoning and your approach to the problem, as well as precisely what difficulties you've encountered. In what way are you using the "gravity" field? What is your conceptual model of player movement and physics? How did you try to incorporate jumping into that model before, and how did it fail? Basically, try to explain your whole situation a bit better, and it will be much easier for others to give you advice. [smile] EDIT: Ah, ninja'd. [lol] rip-off: any particular reason in your code it's subtracting gravitational acceleration from the player's acceleration every frame? Seems to me that once the player is in the air, the acceleration should be constant, since (in this basic example anyway) there are no other forces besides gravity acting on the player. For simplicity, I'd probably treat jumping as an instantaneous impulse giving an initial vertical velocity.
  4. script for flash & C ++

    Well, I don't do a lot of Flash stuff, but to my understanding, there's so little in common between the way games are written in Flash with ActionScript and the way games are usually written in C that it seems like achieving any kind of script commonality would be more trouble than it's worth. Maybe I'm misinterpreting your question? It seems to me that if you want your game to run both on the web and on the desktop, you could just distribute a downloadable copy of your Flash game, without having to rewrite anything. You can also package Flash files as self-running executables if that's what you'd prefer.
  5. I've been thinking lately about ways to serialize game state, and I began thinking about how this would work in a game using a script interface that supports cooperative threads. (Coroutines, or generators, or what have you.) Let's take a simple example and suppose we have a map with an object moving around it whose motion is controlled by a coroutine. Then say we want to save the game at some point, and be able to resume it later with the object picking up exactly where it left off. It seems to me that one option is to build a system in which cooperative threads can be serialized while they are suspended, and then revived at a later time with the same locals and resume point. The game could have a scheduler that manages all cooperative threads, and can serialize them to and from persistent memory along with all the other data that makes up the game's current state. In this way, the behavior of objects within the game can be scripted with cooperative threads without worrying about what happens if a save-and-reload occurs in the middle of their lifetimes; as long as the all the objects are brought back in the correct state, and the scheduler restores itself to the same state as before, things will work smoothly. Another option would be to just serialize your entire VM state, though that seems like an unnecessarily heavy operation. My question is, is this a feasible solution in general? Does anybody actually do this, or is it generally better to restructure your game so that all cooperative threads will terminate before game state is saved? (Or else make script writers operate under the assumption that their threads are not part of the game's persistent state.) I did a bit of searching, and found this thread, which suggests that Lua is capable of doing what I describe, but I'm still curious as to whether this seems like a good idea or not. It seems like it would have a few obvious benefits, including making it possible to write simple, natural entity scripts while basically hiding most serialization from the script interface. It would involve a bit more work on the back end, but I'm not seeing any significant reasons that this wouldn't be a worthwhile option. Any thoughts?
  6. I posted this over on the forum earlier today, but since things seem to move fairly slowly over there, I figured I'd post it here as well to maybe get some quicker feedback. [grin] I'm in the process of designing a simple scriptable game engine. I was originally thinking about using Spidermonkey JavaScript for the project, but when I found Squirrel I was immediately tempted to switch. For my purposes Squirrel has a lot of advantages: it's simpler, much more lightweight, and not encumbered by the extras and security considerations that a browser-targeted system like Spidermonkey includes by necessity. Supporting both generators and cooperative thread semantics is a nice plus. It also looks like embedding is a bit easier than it is with Spidermonkey. However, I'm very used to JavaScript's prototypes and instance-based OOP, and compared to this Squirrel's object semantics seem almost arbitrarily rigid. In JavaScript, all objects are highly mutable; you can dynamically add new properties and methods. Using prototype objects, you can add behaviors to entire families of objects. (On the Squirrel forum, aeyr suggested something like this for Squirrel in this post in the "Roadmap to 3.x" thread.) In Squirrel, the class system is fairly strict. Classes can be modified dynamically, but only before any instances have been created. Class instances themselves cannot have new slots added to them. This enforces the "contractual" interface we would expect from an object based on its class membership, but for a long-time fan of JavaScript, it makes objects seem rigid and inflexible, not quite what a dynamic language should be, especially since Squirrel is duck-typed already. Why enforce class contracts in a duck-typed language? Basically, my thinking is that if Squirrel were just a little bit more like javascript, it would be perfect. I don't know if Alberto Demichelis would think these would be productive changes to the language any time soon, so I was thinking I would try to make some changes for myself and see how they work out. I was thinking of a system in which classes serve only as templates for object construction, and every object's interface would be mutable. Maybe with some prototyping semantics from JavaScript tossed in. I just wanted to get a bit of feedback on if this sounds like it might be a worthwhile idea, or if maybe I would be better off sticking with JavaScript or learning to accept the rigid classes of Squirrel. I have a bit of experience writing compilers, but not a whole lot on the practical side, so I'm not completely familiar with the sort of obstacles I might encounter. Any advice would be appreciated. [smile]
  7. Saving drawn objects

    Quote:Original post by EasilyConfusedI assume MFC provides a virtual function or something you can use to respond to WM_PAINT under the hood. Yep; just override OnPaint() in your CDialog-derived class, and create a CPaintDC in that method to do your drawing. Then all your drawing code will be run every time the window is invalidated.
  8. Quote:Original post by LessBread No. It means that people have the right to keep and bear arms in expectation of being called by the State government to serve in "a well regulated militia" as needed to provide for the common defense. If there is no expectation of being called to serve in the state militia, there is no justification for keeping or bearing arms. If anything, the 2nd amendment and 18th century practice would indicate that every able bodied male should be drafted into state militias. Earlier in the discussion I stipulated National Guard, but in as much as the National Guard is a part of the Army, such a draft wouldn't jibe with the 2nd amendment. If the common defense of security were the only purpose of a citizen militia, I would not have much of a problem with this interpretation, though I still think it is wishful thinking to inject a connotation of purposeful restriction into a statement of justification. But you are ignoring the other purpose of an armed citizenry, which many of the founders were quite unambiguous about in their writings. Quote:I think there is a lot we can do to reduce the number of "violent freak outs" - from better mental health care onwards. I think throwing our hands up and saying there's nothing we can do only guarantees that such massacres will happen again and again and again as they have for decades now. I don't think I phrased that quite as well as I intended - I meant that attempting to restrict or prohibit dangerous articles can have only a very limited effect on such crimes of insanity, since there are plenty of opportunities for a truly unhinged person to cause mayhem that we can never eliminate. I certainly did not mean that there's "nothing we can do" There is much that can be done, and trying to make sure mentally unstable people cannot purchase firearms is a good start, but it won't be enough. Quote:Some things more important than our lives? That sounds to me like a high fallutin' cop-out along the lines of: "Freedom's untidy, and free people are free to make mistakes and commit crimes and do bad things." It's not a cop-out; it's just my belief. I'm genuinely grateful to all who have sacrificed in the name of liberty, and I feel it is my duty to be willing to do the same. Where do you get the idea that I think people are "free" to commit crimes? Quote:Would you tell the parents that lost children in this incident that gun rights are more important than their children's lives? I doubt that you would. Please. This is an entirely emotional argument. I would never presume to say anything so callous to a grieving family, and I'm not going to try to put a "price" on any one life. But the simple fact is that if guns exist in our society, people will die by them. We should do what we can to reduce the toll, but I believe that the right to bear arms is fundamentally important and that some price will have to be paid. I'm well aware that it might just be me that winds up being gunned down by a psycho someday, but it's a risk I'm willing to take. EDIT: And what's all this about charging the guy who sold Seung-Hui his gun? If it can be shown that he violated state or federal law when he made the sale, then certainly charges will be appropriate. But from what I've heard, the purchase was quite legal when it occurred. Have I been misinformed?
  9. Quote:Original post by LessBread The issue of gun control has been raised in reaction to the event. That makes raising the issue reactive (ie. characterized by reaction) but not reactionary (ie. opposing political or social change). Well, I stand corrected. Quote:By protecting military weapons that ruling lends credence to the "National Guard" interpretation of the 2nd amendment - despite the 2004 DoJ memo to the contrary. Why? The Miller case particularly concerned individual possession and transportation, though considerations relating to this fact were never made part of the Court's discussion. The fact that the Supreme Court indicated that the Second Amendment protected firearms with current military application simply does not speak to the issue of collective rights versus individual rights. You could just as well argue that the Miller decision implicitly supported individual rights, since the contrary interpretation was not used to rule against Miller instead! It seems pretty clear to me that the intent behind the Second Amendment was to ensure the ability of a citizen militia to exist outside of the control of the government. If it were under the control of the government, it would be unable to serve the purpose that the founders wanted to prepare for, even while they were doing their best to prepare against it. Quote:The prefatory clause and the operative clause are both two clauses, so there are four clauses all together: "A well regulated militia" and "being necessary to the security of a free State" and "the right of the People to keep and bear arms" and "shall not be infringed." I don't have the time or inclination to read all 107 pages of the memo - and I seriously doubt that you did either when you asserted that it's arguments were sound and damning. Perhaps there's a specific item in the memo that you'd like to discuss? Otherwise, go fish! [smile] Is there a particular reason you think the division of those subclauses is relevant? I don't quite see how it aids any analysis to further separate the prefatory and operative sections of the amendment. And actually, I did read the memorandum in its entirety last year when I first learned of its existence. If you'd like to discuss specific points: - What makes you think the prefatory declaration places restriction on the operative assertion that "the right of the People to keep and bear arms shall not be infringed"? - Do you think that "the right of the People" in the amendment means "the right of the Government", and if so, what support do you have for this interpretation? Quote:Quote:Original post by MrAccident To a certain extent, I agree, which is why I think better education is very important as well. However, I feel that the top priority (as regards gun control laws specifically) is to keep firearms available to responsible, law-abiding citizens. Requiring training and permits for handgun ownership seems to me like a good way to attempt to screen out those who are not responsible. Annual training and permits are good, but it would seem that psych screenings are needed as well (especially in light of ptsd in veterans). That said, I think we focus too much on handgun owners and not enough on handgun makers. I don't mean responsible companies (ie. those with household names), I mean the fly-by-nighters that make cheap guns and dump them into our cities. It seems that the right of gun makers to turn a buck far too often out strips the rights of gun violence victims. Well, we're more or less in agreement about handguns then. Don't mistake me, though - I doubt very much that there's all a whole lot we can do to prevent incidents like this one, gun control or no. Cracking down on gang activity and cheap illegally sold guns may certainly help reduce street crime (and, IMHO, more well-trained CCW holders helps here as well), but I frankly don't think there's anything we can do to stop the occasional deranged individual from snapping and killing a bunch of people. If not handguns, a hunting rifle. If not a rifle, a bomb. If not a bomb, an automobile driven into a crowd. There are far too many ways to wreak havoc - the only hope we have is to try to pay more attention to troubled individuals, and hopefully get them the help they need before they snap. I guess, bottom line, I can sum up my feelings thusly: Life is risky. Freedom is not safe. We should all attempt to provide reasonable protections for our safety and prosperity, without forgetting that there are some things more important than our lives.
  10. Quote:Original post by LessBreadSo you don't know what the word reactionary means either? Apparently not. I meant that raising the issue of gun control was a reaction specifically to the event. If "reactionary" doesn't describe something that is primarily in reaction to something else, then I confess ignorance on that point. Quote:#1 United States v. Miller The Supreme Court declared that no conflict between the NFA and the Second Amendment had been established,writing ... we cannot say that the Second Amendment guarantees the right to keep and bear such an instrument[sawed off shotgun]. The National Firearms Act imposes a statutory excise tax on the sale of machine guns among other weapons. The transfer tax of $200 placed on the transfer of firearms controlled by the Act was roughly equivalent to five months' salary in 1934. That was exactly my point; in deciding against Miller, the Court stated its opinion that the Second Amendment specifically protected military weapons. Hence: handguns and shotguns, not so protected; assault rifles and .50-cal, protected. I happen to disagree with the court's narrow interpretation of what constitutes military small arms, but for what it's worth it's the closest thing we have to a Supreme Court interpretation of the second amendment. Quote:#2 Anything coming from this corrupt DoJ isn't worth the paper it's written on. What's damned is this DoJ and it's crooked AG. For all we know, the NRA wrote that memorandum for the DoJ. I did point out that the memorandum has no legal status - however, having read it carefully, I believe the argument presented is valid. Regardless of how much I despise the Attorney General (and in large part, recent actions of the DOJ itself), the memorandum seems like a convincing argument to me. Maybe you'd like to raise some specific issue with it that could be debated? Quote:#3 10 U.S.C. 311 is there to facilitate military conscription. From U.S. v. Miller: These show plainly enough that the Militia comprised all males physically capable of acting in concert for the common defense. 'A body of citizens enrolled for military discipline.' And further, that ordinarily when called for service these men were expected to appear bearing arms supplied by themselves and of the kind in common use at the time. So when you're drafted, don't forget to bring your shotgun with you to the service examination! [smile] Will do! [smile] Quote:The reactionary measure is to continue business as usual (and that's what it would be a continuation of business) regarding guns and to instead clampdown on the first amendment, which is what shifting the blame to "cultural problems" amounts to. It seems to me that not focusing on guns amounts to sticking our heads in the sand. After each of these massacres we don't seriously focus on guns and soon enough another massacre and another massacre and another massacre happens. As I keep saying, asserting that the problem is cultural is to admit that our culture does not produce enough sufficiently mature adults to allow any random citizen to own guns. To a certain extent, I agree, which is why I think better education is very important as well. However, I feel that the top priority (as regards gun control laws specifically) is to keep firearms available to responsible, law-abiding citizens. Requiring training and permits for handgun ownership seems to me like a good way to attempt to screen out those who are not responsible. Quote:I think it depends on what you mean by crime. Here's a list of incidents: Criminal Use of the 50 Caliber Sniper Rifle. Many of these are technical crimes, that is, a suspect was arrested for some other crime and these guns turned up during a search of their vehicles or homes. However, note the case of Donin Wright: In February of 2004, Donin Wright of Kansas City, Missouri, lured police officers, paramedics, and firefighters to his home where he shot at them with several guns including a Barrett 50 caliber sniper rifle. Also note the case of Albert Petrosky: Petrosky, who was known to his friends as "50-cal Al," fired all four weapons, including the 50 caliber rifle, during his murderous rampage. And let's not forget this: Branch Davidian cult members at a compound in Waco, Texas, fired 50 caliber sniper rifles at federal ATF agents during their initial gun battle on February 28, 1993. And lastly, the account of an attack on an armored truck in Chamblee, Georgia in 1992 where the two guards were shot with a Barrett. Ah, thank you for bringing that to my attention; I hadn't been aware of those incidents. Still, .50 caliber rifles are so infrequently (and relatively ineffectively) used in crime, I think they're hardly worth even batting an eye at. More effective and well-enforced handgun laws will go a very, very long way towards curbing gun violence, so I would say that should be the focus of any reasonable gun control effort. Also, it simply must be pointed out that .50 caliber is the most effective round for hunting dangerous game like squirrels. (...Actually, I'm morally opposed to hunting, but I just can't say the phrase "exploding squirrels" in my head without giggling. Tee-hee! [grin])
  11. First, I'll agree with previous posters who said this is a reactionary debate, and as such everybody should try to distance themselves from the emotional impact of the recent tragedy to discuss the issue in an objective fashion. Now, I'd like to address the "2nd Amendment is outdated" idea. Of interest here is the 1939 United States Supreme Court decision in United States v. Miller, in which the court's opinion indicated that the Second Amendment specifically protects military assault weapons; this argument was used to rule against Miller, who was in trouble for having a sawed-off shotgun, the shotgun being deemed not useful enough in military application to be protected. (Of course, short-barrelled shotguns are and were used in the military, though the Supreme Court was apparently unaware of this.) Then there's a 2004 memorandum from the Department of Justice that affirms an interpretation of the Second Amendment conferring the right to bear arms to citizens individually, and not as a collective or in terms of service in a militia or the National Guard. Specifically, it argues that the prefatory clause of the amendment ("A well regulated militia being necessary to the security of a free State") cannot be read to construe any restriction whatsoever on the operative clause ("the right of the People to keep and bear arms shall not be infringed"). This memorandum, of course, has no actual legal weight, but I believe its arguments are sound and damning. Finally, if that weren't enough, there's 10 U.S.C. 311, which defines the militia of the United States of America as consisting of, not only the National Guard, but every male citizen between the ages of 17 and 45. That is, if you're a male living in the United States of America, there's a pretty good chance you're already a member of the militia. Now, for the part that's just my personal opinion, and to respond to a few specific comments: I think that handguns should be, in general, more tightly regulated than they are now. I believe very strongly that every law-abiding citizen should be able to obtain a handgun, and a license to carry it in public, provided they pass background checks and rigorous training in firearms safety, judgement, and unarmed self-defense. As it is, there are some states where you don't even have to attend a cheap safety seminar to obtain a CCW permit, which strikes me as a little crazy. CCW holders should represent absolutely the highest caliber of responsible armed citizens. Handguns are used in by far the vast majority of gun crimes. They are also, by the intent of the framers of the United States Constitution and the later interpretation of the Supreme Court, afforded the least protection under the Second Amendment, so I have no problem regulating them in this fashion. LessBread, I've found that I agree with you on most issues, but definitely not this one. To give a slightly facetious response to your thread title: "How Many More People Must Die In Drunk Driving Accidents Before The United States Gets Real About Alcohol Control?" Just because something is dangerous doesn't mean it should be illegal. I have been personally present at two on-campus shootings - one at a community college I was attending, and one more recently here at the University of Washington. I was walking past the architecture building on my way to work around the time the shooting took place. Both these events made me feel a bit nervous - I became very aware of the possibility that someone with a gun might on some random day decide to snuff out my life. However, I still believe the right to bear arms is more important than my personal sense of risk. I agree that tragedies like this one are terrible, but I do not believe they merit reactionary measures, except, as I noted above, to the extent that I believe handguns should be more regulated. However, I believe that in order to do anything about our country's serious problem with violence, we're going to have to address much more than handguns - the problem is cultural, and focusing on guns as a scapegoat is just so much sticking of heads in the sand. Quote:Original post by Nemesis2k2 Ok, so ideologically, you primarily approve of general availability of weaponry to support self-reliance and personal responsibility for one's safety. Let me ask you a hypothetical question: If it was an absolute certanty that bringing in gun control would result in a significant reduction in murder rates per year in the US, would you still oppose this legislation? Depends what you mean by "gun control". If you mean "more sensible restrictions and better enforcement regarding handguns", then I would support it. If you meant "banning handguns or banning / further regulating assault weapons", I would oppose it. Quote:Original post by Mithrandir Also I love the whole "we need guns so that the government doesn't take away our rights!" A) first of all, you already let them do that by supporting your favourite monkey and his PATRIOT Act, illegal wiretaps, etc, etc. B) Yeah, have fun trying to stand up against an M1A1 Abrams tank with that 9mm. C) Or an A-10, F-22, B-2, etc. Fuck we probably couldn't even stand up against a B-52. I'd love to see you try to get your hands on an SAM and claim it's an essential liberty granted under the 2nd ammendment. Well, look what all our high-tech killing equipment is amounting to in Iraq. Make no mistake: if another revolution were to occur in this country, it would be horribly bloody. No sane person wants that to happen, but the Second Amendment is there to provide for that most dire of last-ditch measures. With regard to your point (A), I agree that way too many Americans are ignoring the safeguards against tyranny that were built into our system of government. If they can't even be bothered to vote responsibly, they'll certainly be too lazy to revolt. That's why I also support greater civic education - that, I think, should be a higher priority than ensuring gun rights, though I still believe that gun rights are also important. Quote:Original post by Promit For the record, I just want to say that I'm feeling thoroughly vindicated about strong-arming this topic out of the VA Tech thread. I'll say! Definitely a good call. [smile] One brief question: At least one person expressed the opinion that large weapons like .50 caliber rifles should be illegal. Why? To my knowledge, a .50 caliber rifle has never been used in any crime in the U.S., and with good reason: they're huge, heavy, and cumbersome to reload. On the other hand, they're a lot of fun to shoot. [smile] And, just as a final remark, though I very strongly support the Second Amendment, I think the NRA are a bunch of nutbags. [grin]
  12. Need help with table comparisons

    I think he means the code frames in forum posts. [smile] Like so: [ source lang="cpp"] Your code goes here [/source] (Omit the space from the opening tag)
  13. Desperately need need help on java error

    Your constructor doesn't match how you're trying to call it. Warden Ward = new Warden(firstName, surName, birthday, gender, WardenID) It looks like you're missing the first two string arguments that your constructor requires. Also, here you're trying to pass WardenID, which is a string, when your constructor expects an integer ID as its last argument. If you read WardenID as an integer (or converted it before passing) then it looks like you would be matching the signature of your Person constructor, but that's not what you're calling. Your constructor call needs to match the signature of the constructor you've defined for the Warden class. EDIT: actually, it looks like the last parameter should be telephone number, not Warden ID. My mistake. Still, you need to look at your constructor definition more carefully when trying to call it. [smile]
  14. realllly basic char* question

    Yes, you should definitely be using std::string instead of C-style strings. Code in C++, not FrankenC. [grin] That aside, though, I see two problems with this code: char* rt_Material::getTextureName(){ cout<<"Texture name: "<<*texture_name<<endl; return rt_Material::texture_name; }First, you're dereferencing your texture_name pointer. If your intention is to print the string, you should not do this. Note that your cout statements in the constructor do not do this. Second, you're returning rt_Material::texture_name, as though it were a static variable, when it pretty clearly is not. This should not even compile; was this just a transcription error, perhaps?
  15. Microsoft Visual C++ 6.0

    Quote:Original post by NumsgilIn essence, if you've never programmed a day in your life, you might be better off starting with MSVC 6 than trying to download all the different express editions and their dependancies. They can be a little frustrating to set up. If you know what you're doing, the express editions are much better. I still think I'd recommend Visual C++ 2005 Express, even if you have to download the platform SDK before you can write Win32 apps. He says he wants to learn C++ this summer; how can he do that without a compiler that's at least almost standards-compliant? [wink] JBourrie, I hadn't thought of the licensing issue, but that's a very good point as well.