|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On January 03 2012 02:09 MisterD wrote:Show nested quote +On January 02 2012 22:58 Roban wrote:On January 02 2012 22:18 MisterD wrote: public Person (String name, int age, int mm, int dd, int yyyy){..} Person First = new Person (First, 15, 01, 01, 1991);
that doesn't really match by the way.. you should have:
Person First = new Person ("First", 15, 01, 01, 1991);
also, you should get used to writing variable names in lower case, so ideally it would be:
Person first = new Person ("First", 15, 01, 01, 1991);
same with second, third obviously.
Eh, don't type 01, 02, 03 as an integer value unless you mean octal.... in this case ( 01 ) it's still 1 but if you type 010, it's actually 8 instead of 10 without looking it up right now, i am quite certain, that 010 is still decimal 10 and you have to write 0x10 to get the hexadecimal 8, at least in java.
Well, there is a difference between hexadecimal and octal, but I suppose you are partially right in that you do have to write 0x... to get hexadecimal.
Take it from me though and just don't start typing numbers with a leading 0 because you might regret it someday after a lot of hours of debugging...
Also, 0x10 hexadecimal == 16 in decimal
Although base 10 is a convenient way to write numbers in a program, occasionally you'll want to write numbers in octal or hex (for int values). Fortunately, C/C++/Java makes this simple.
To write numbers in octal, precede the value with a 0. Thus, 023 is 238 (which is 19 in base 10). To write numbers in hexadecimal, precede the value with a 0x or 0X. Thus, 0x23 is 2316 (which is 35 in base 10).
http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/hexoctal.html
Integer Literals Integer literals is a sequence of digits and a suffix as L. To represent the type as long integer we use L as a suffix. We can specify the integers either in decimal, hexadecimal or octal format. To indicate a decimal format put the left most digit as nonzero. Similarly put the characters as ox to the left of at least one hexadecimal digit to indicate hexadecimal format. Also we can indicate the octal format by a zero digit followed by the digits 0 to 7. Lets tweak the table below.
659L Decimal integer literal of type long integer 0x4a Hexadecimal integer literal of type integer 057L Octal integer literal of type long integer http://www.roseindia.net/java/language/java-literals.shtml
|
On January 03 2012 02:35 ParasitJonte wrote:Show nested quote +On January 02 2012 22:31 Warri wrote: Can anyone recommend me a rather recent tutorial on how to create 3d games in java? All i can find with google are tutorials from 2004 and older, but i guess a lot changed since then so its better to use a more recent one? Go with jmonkeyengine http://jmonkeyengine.com/ . Seems like a very serious project. Think they also support games on android if you want to do that.
Thank you!
I'm playing around with it rightnow and its so freaking easy to learn how to use their framework :D
|
On January 02 2012 22:28 FranzP wrote:Show nested quote +On January 02 2012 16:46 ccherng wrote: Does anyone have a detailed explanation of how to use cookies to implement both of the following logins securely.
1) Login meaning either one time login that which is NOT persistant meaning when the browser is closed a new browser is opened to the site a new login is required.
2) Login meaning its persistent for some number of days like you usually see with sites like gmail.
How does one implement this using raw html, javascript for the frontend, and SQL, C++ with a very barebones basic html server for the backend. I would like to understand the low level details. I don't want to see some PHP high level implementation. Oh and it needs to be ultra secure. When you say C++ do you use a web framework or just pure C++. Because I actually have no idea how to develop a web site with just C++ (and I don't think a lot of people do). I ask that because you won't go anywhere without a big layer of abstraction to handle session and cookie. At least HttpRequest, HttpResponse, Cookie and Session object. The security behind your web site doesn't depend on the language you use but more on how people can interact with it and how you deal with interaction (a website without any user interaction like comment etc will be a lot safer). As for your points : 1) You should just store a sessionID in a session cookie. It will reset itself when the browser is closed (or leave the website) then reopened. 2) just store a sessionID in a persistent cookie and save it to your DB. He you want to be extra safe use a secure cookie and HTTPS If you want to understand more about session and cookie implementation just go look for it there is plenty of documentation on different implementation. http://en.wikipedia.org/wiki/HTTP_cookie provides a lot of explanation. The point is, you can't be more secure than cookie let you be. You can generate the httpresponse with the cookie yourself but I don't think there is any point in that. Just PHP or something else. If you're just curious about cookie implementation read the HTTP specification :D
Let me refine what I am asking. Aren't there various kinds of security holes potentially. You can't just "store" information in the cookie without thinking through things like cookie hijacking. Isn't there suppose to be some use of cryptography in using cookies to prevent these types of problems?
|
Yeah use HTTPS. Other than that cookie are like everything you send or receive it's visible to anyone on the line.
If you think about cookie jacking using XSS, the cookie doesn't matter and that's yours to make your website xss proof.
|
So I figure I've wasted a lot of time this break. What should I spend my time on programming to not feel like complete horseshit? I'm reviewing some lynda videos right now but the ones on excel and ios are just really boring.
|
On January 03 2012 06:30 fabiano wrote:Show nested quote +On January 03 2012 02:35 ParasitJonte wrote:On January 02 2012 22:31 Warri wrote: Can anyone recommend me a rather recent tutorial on how to create 3d games in java? All i can find with google are tutorials from 2004 and older, but i guess a lot changed since then so its better to use a more recent one? Go with jmonkeyengine http://jmonkeyengine.com/ . Seems like a very serious project. Think they also support games on android if you want to do that. Thank you! I'm playing around with it rightnow and its so freaking easy to learn how to use their framework :D
Awesome. I've been thinking about testing it since some friends did some cool physics engine stuff with it, but haven't found the time. Whenever I do I'll be sure to try it, wasn't sure how easy/good it was .
|
|
java programmers to the front:
i am looking for code examples that make use of annotations for method invocations. Popular examples are, for instance, @Before, @Test and @After in JUnit test cases - these annotations specify points in time when the annotated methods will be executed. A newer example would be @PostConstruct from java's new dependency injection, which makes the annotated method being called after dependency injection is done. Also from dependency injections, @Inject itself on methods causes these methods to be invoked once or multiple times.
However, with that, i'm currently kinda out of ideas where else annotations are used for code execution. So my question is: Can anyone link me to other frameworks or code examples, that use annotations to let client code methods be invoked?
|
Hey people
Me and 3 fellow students are about to make a 3 week programming project in java. The goal is to make some Voice over IP software, with a (hopefully) bitrate around 64kbit/s - 8000 samples/s with 8 bit pr. sample. We are all telecommunication engineering students, on our first year, so our programming experience is somehow limited. We've done some intro courses in java, and know a little bit about GUI and network programming - sockets. The goal is to make the GUI really simple, and focus on the code making the speech and send/recieving it.
So my question is if anybody could recommend sites, guides, tutorials or other helpfull stuff, to get started and what to focus on.
Hopefully my english is not unreadable, if it is, i apologize! Feel free to PM me with further questions if you are willing to help.
Kanaz
EDIT: The program needs to work over the internet, and prerferable we make our own protocol instead of using existing ones.
|
On January 04 2012 21:53 MisterD wrote: java programmers to the front:
i am looking for code examples that make use of annotations for method invocations. Popular examples are, for instance, @Before, @Test and @After in JUnit test cases - these annotations specify points in time when the annotated methods will be executed. A newer example would be @PostConstruct from java's new dependency injection, which makes the annotated method being called after dependency injection is done. Also from dependency injections, @Inject itself on methods causes these methods to be invoked once or multiple times.
However, with that, i'm currently kinda out of ideas where else annotations are used for code execution. So my question is: Can anyone link me to other frameworks or code examples, that use annotations to let client code methods be invoked?
Hibernate uses annotations for mapping. EJB 3 uses it for ORM too. The wikipedia page for annotation has a lot of information http://en.wikipedia.org/wiki/Java_annotation .
Here is a good guide of how annotation work and how to use them in java. http://isagoksu.com/2009/development/java/creating-custom-annotations-and-making-use-of-them/
Hope this helps.
|
On January 05 2012 03:18 FranzP wrote:Show nested quote +On January 04 2012 21:53 MisterD wrote: java programmers to the front:
i am looking for code examples that make use of annotations for method invocations. Popular examples are, for instance, @Before, @Test and @After in JUnit test cases - these annotations specify points in time when the annotated methods will be executed. A newer example would be @PostConstruct from java's new dependency injection, which makes the annotated method being called after dependency injection is done. Also from dependency injections, @Inject itself on methods causes these methods to be invoked once or multiple times.
However, with that, i'm currently kinda out of ideas where else annotations are used for code execution. So my question is: Can anyone link me to other frameworks or code examples, that use annotations to let client code methods be invoked? Hibernate uses annotations for mapping. EJB 3 uses it for ORM too. The wikipedia page for annotation has a lot of information http://en.wikipedia.org/wiki/Java_annotation . Here is a good guide of how annotation work and how to use them in java. http://isagoksu.com/2009/development/java/creating-custom-annotations-and-making-use-of-them/Hope this helps.
no not really, these are annotations defining attributes, not calling contexts. i'm looking for examples that use annotations to call methods. Defining an O/R mapping like "this field goes in the database" or a @Deprecated API doesn't define points where my methods are executed. Stuff like @After/@Test/@Before in Junit works like "well first, all @Before methods will be called, then all @Test methods and at the end all @After methods will be called so you can clean up". having an @Entity or @Column on a field for instance doesn't match that pattern, it just adds additional bits of (meta-level) information to the annotated member for other frameworks to use. but thanks anyways.
|
Possibly quick question.
I am writing a simple game in C++ with OpenGL. It's basically a slightly more complex version of Asteroids.
The problems I'm having, are with spawning new targets. I want them to spawn at random positions on the screen, and move in a random direction. C++'s rand() method isn't anywhere near random enough however. In test runs, I can see that enemies always spawn in the same spots and move in the same direction. Can anyone either give me some help with RNG's, or maybe point me in the right direction?
Also, I need to be able to ensure that targets will not spawn on top of the player. Dying because an enemy appeared on you is pretty unfair, and not good game design. How can I do this?
|
On January 05 2012 04:35 Millitron wrote: Possibly quick question.
I am writing a simple game in C++ with OpenGL. It's basically a slightly more complex version of Asteroids.
The problems I'm having, are with spawning new targets. I want them to spawn at random positions on the screen, and move in a random direction. C++'s rand() method isn't anywhere near random enough however. In test runs, I can see that enemies always spawn in the same spots and move in the same direction. Can anyone either give me some help with RNG's, or maybe point me in the right direction?
Also, I need to be able to ensure that targets will not spawn on top of the player. Dying because an enemy appeared on you is pretty unfair, and not good game design. How can I do this?
You probably didn't seed rand()? http://www.cplusplus.com/reference/clibrary/cstdlib/rand/
As for your second point, you can just keep on generating random positions until you get a position that's some distance from the player?
|
On January 05 2012 04:35 Millitron wrote: Possibly quick question.
I am writing a simple game in C++ with OpenGL. It's basically a slightly more complex version of Asteroids.
The problems I'm having, are with spawning new targets. I want them to spawn at random positions on the screen, and move in a random direction. C++'s rand() method isn't anywhere near random enough however. In test runs, I can see that enemies always spawn in the same spots and move in the same direction. Can anyone either give me some help with RNG's, or maybe point me in the right direction?
Also, I need to be able to ensure that targets will not spawn on top of the player. Dying because an enemy appeared on you is pretty unfair, and not good game design. How can I do this?
Well, make sure you have a random seed for the random method. Otherwise you'll get the same things happening over and over. Alternative you could make your own random method, I'm sure you can find a good one already made for C++ somewhere online.
Not spawning on the player is easy, just make a check that the spawn position of the target isn't within a certain distance of the player's current position before spawning it.
|
I'm a high school student with some minor C++ experience applying for computer science in University and I'm worried that I will be unprepared for the programs and the workload I might face, anyone who is currently in one of these courses or gone through it recently help me get a grasp on what I'm digging myself into?
Also I'm currently attempting to teach myself Java however I'm struggling to find a tutorial that actually teaches you how to code and not just the concepts of the language. Any suggestions would be helpful.
|
On January 05 2012 04:59 killa_robot wrote:Show nested quote +On January 05 2012 04:35 Millitron wrote: Possibly quick question.
I am writing a simple game in C++ with OpenGL. It's basically a slightly more complex version of Asteroids.
The problems I'm having, are with spawning new targets. I want them to spawn at random positions on the screen, and move in a random direction. C++'s rand() method isn't anywhere near random enough however. In test runs, I can see that enemies always spawn in the same spots and move in the same direction. Can anyone either give me some help with RNG's, or maybe point me in the right direction?
Also, I need to be able to ensure that targets will not spawn on top of the player. Dying because an enemy appeared on you is pretty unfair, and not good game design. How can I do this? Well, make sure you have a random seed for the random method. Otherwise you'll get the same things happening over and over. Alternative you could make your own random method, I'm sure you can find a good one already made for C++ somewhere online. Not spawning on the player is easy, just make a check that the spawn position of the target isn't within a certain distance of the player's current position before spawning it. How do I get a random seed?
I've been reading http://www.cplusplus.com/reference/clibrary/cstdlib/srand/ and it doesn't really say how I should select my seed. Should it be something like srand(rand()) every time I need to spawn something?
On January 05 2012 12:32 Leftwing wrote: I'm a high school student with some minor C++ experience applying for computer science in University and I'm worried that I will be unprepared for the programs and the workload I might face, anyone who is currently in one of these courses or gone through it recently help me get a grasp on what I'm digging myself into?
Also I'm currently attempting to teach myself Java however I'm struggling to find a tutorial that actually teaches you how to code and not just the concepts of the language. Any suggestions would be helpful. First, most schools will have you take an introductory programming course which requires little or no prior knowledge.
Second, as far as you're concerned, Java and C++ are the same, unless you're some really advanced high school student writing complex programs which require careful memory management.
|
On January 05 2012 12:32 Leftwing wrote: I'm a high school student with some minor C++ experience applying for computer science in University and I'm worried that I will be unprepared for the programs and the workload I might face, anyone who is currently in one of these courses or gone through it recently help me get a grasp on what I'm digging myself into?
Also I'm currently attempting to teach myself Java however I'm struggling to find a tutorial that actually teaches you how to code and not just the concepts of the language. Any suggestions would be helpful.
Most people go into university with no actual coding experience, so you're already ahead of the game! In fact, I'm halfway through my junior year of computer science and I still feel like I barely know how to code my way out of a paper bag.
|
On January 05 2012 12:32 Leftwing wrote: I'm a high school student with some minor C++ experience applying for computer science in University and I'm worried that I will be unprepared for the programs and the workload I might face, anyone who is currently in one of these courses or gone through it recently help me get a grasp on what I'm digging myself into?
Also I'm currently attempting to teach myself Java however I'm struggling to find a tutorial that actually teaches you how to code and not just the concepts of the language. Any suggestions would be helpful.
As some have said, in university, they assume you have no prior coding experience so don't worry. Just keep ahead of the class, read the book, etc. As for Java, if you are willing to buy a book or download as an eBook, I recommend Absolute Java by Savitch.
|
Edit: There's a pause function in the CCDirector which I can use. Only downside is that it'll pause all schedule methods. So my new layer can't use any schedule method which sucks but I can live with that. If someone knows another way, feel free to pm me :D
Anyone familiar with Objective-C regarding Cocos2D framework?
I just started with game programming and I'm making a 2D RPG turn based fighting game (check my blogs) and I had a couple of questions (which I presume any person with C knowledge should also be able to help me out).
So I have a couple of CCLayers in a Scene which I use for different tasks. E.g. one of them is a CCLayer which handles all progress bars for all the players.
Now when I want to pause my game I want to have another layer on top while all remaining layers are actually paused except for 1. The way I have it now is that I have an if statement in the schedule method of every CCLayer that checks if the layer should be paused or not and then make 1 CCLayer and place it on top of all CCLayers which will be my menu screen.
This works fine but there's too much stuff that's running behind that it drains the battery life of the iPad and I'm quite sure that there are way better methods to do such things and I as a beginner don't know anything better yet.
So my question is if anyone has a better suggestion :D
I've read on the cocos forums and other sites that I should use the onEnter and onExit methods and as far as I understand with my limited mind I should just deallocate a specific CCLayer and just allocate the CCLayer again when I unpause. This should set the battery usage as low as possible but does this mean that I need to save all the CCLayer data first and store it somewhere else and when I allocate it again just load that data up again or is there some method that does this :D ?
|
On January 05 2012 18:21 Herper wrote:Show nested quote +On January 05 2012 12:32 Leftwing wrote: I'm a high school student with some minor C++ experience applying for computer science in University and I'm worried that I will be unprepared for the programs and the workload I might face, anyone who is currently in one of these courses or gone through it recently help me get a grasp on what I'm digging myself into?
Also I'm currently attempting to teach myself Java however I'm struggling to find a tutorial that actually teaches you how to code and not just the concepts of the language. Any suggestions would be helpful. As some have said, in university, they assume you have no prior coding experience so don't worry. Just keep ahead of the class, read the book, etc. As for Java, if you are willing to buy a book or download as an eBook, I recommend Absolute Java by Savitch.
I've been searching for the 4th edition for the last 30 minutes or so and am having a hard time finding a PDF version, but I think I found an earlier edition. If it wasn't 100$ I would have probably already bought it, but like most people I'm broke and trying to save what I have to survive the next four years.
|
|
|
|