Jump to content

  • Log In with Google      Sign In   
  • Create Account


code for a 2d java game?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Jeffige   Members   -  Reputation: 113

Like
0Likes
Like

Posted 16 August 2012 - 12:44 PM

I have started to learn java so I could create 2D games for Android. Out of curiosity, does anyone know

where I could find a simple open source 2D game so I could look over the code? It may help ( even if I don't fully understand it, yet) to actually see code and how it was written out.

A side scrolling game would be perfect since that is what I am aiming for. But, beggars can't be choosy.

Thanks for any recommendations.

Sponsor:

#2 Shippou   Members   -  Reputation: 1334

Like
0Likes
Like

Posted 16 August 2012 - 01:09 PM

http://www.youtube.com/playlist?list=PLA331A6709F40B79D

 Reactions To Technologies:
1. Anything that is in the world when you’re born is normal and ordinary and is just a natural part of the way the world works.
2. Anything that's invented between when you’re fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it.
3. Anything invented after you're thirty-five is against the natural order of things.

- Douglas Adams 2002


 


#3 David.M   Members   -  Reputation: 731

Like
0Likes
Like

Posted 16 August 2012 - 03:30 PM

Are you using a framework, engine, or just Android API?

Android API: Check out Replica Island. It's a big game but you should be able to pick it apart.

Framework or engine: Depends on the framework or engine. LibGDX has some projects to look at.

#4 Jeffige   Members   -  Reputation: 113

Like
0Likes
Like

Posted 16 August 2012 - 07:44 PM

Thanks guys.

David M, as of now, I just started to learn java (any programming for that matter) a few weeks ago. Self teaching/ learning with java, A beginners guide 5th ed. So, framework or engine? Couldn't tell ya.

I was just thinking if I looked over the code from an actual 2D java game, it may help me to understand as I learn along. As for Android, that is my ultimate goal.

Again, thanks for the help.

#5 David.M   Members   -  Reputation: 731

Like
0Likes
Like

Posted 16 August 2012 - 10:50 PM

Read that wrong, sorry. I thought you were starting Android development. If you're just starting Java then I would pick up a book to learn the basics of the language. From there you can start to branch off into games. Start simple! Build tic-tac-toe as a console game. From there work up to basic graphics (drawing images on-screen and simple movement). You won't be able to use OpenGL with straight Java so drawing will reside in a frame of some sort (JPanel or something). Then you can move on to a Snake game and Space Invaders; more complicated games. Then you can pretty much go on to wherever you like. Jumping to Android wouldn't be too difficult from there, just learning the Android API.

If you decide along your journey into graphics programming that Swing is awful then look into some of the more popular OpenGL-based frameworks and libraries like Slick2D (Windows/Linux/Mac), LibGDX (Windows/Linux/Mac/Android), or a Java wrapper of OpenGL like LWJGL.

As far as examples go, for Swing there is Zetcode with its 2D games tutorials. I got started with it but don't recommend it. It uses a fixed Timer for movement which will be variable based on how fast your machine runs. You'll be much better off learning things right and using a delta time-step. Take a look at Kevin Glass' work. He wrote Slick2D. For Slick examples visit the SlickWiki. For LibGDX, go to the LibGDX wiki and git. LWJGL has examples but it's tougher to get started in.

#6 Jeffige   Members   -  Reputation: 113

Like
0Likes
Like

Posted 17 August 2012 - 12:58 PM

If you're just starting Java then I would pick up a book to learn the basics of the language.


Wow! Thanks David. That is more & concise info that I have read in one spot. Actually, after searching a couple of weeks
for a good starting java book, I eneded up with java, A beginners guide 5th edition. I have read, although I do not need to know complete java, I do need to know the core. After that, I can start on Android while still learning java.

As for frameworks & libraries, No Idea! I have not gotten to that intersection, yet. I do know that I only want to create simple 2D games like Tetris, Space invaders, Tumbl on Android, and some simple kid games like where they snap the puzzle pieces into place and an ABC learning game.

On one of the posts here at gamedev.net I read someone mentioned this (sorry I have forgotten who exactly)

A complete understanding of the basics would be desirable.
Specifically the following topics:
•Declarations and Access Control
•ObjectOrientation
•Assignments
•Operators
•Flow Control, Exceptions, and Assertions
•Strings, I/O, Formatting, and Parsing
•Generics and Collections
•InnerClasses
•Threads

I know even a simple 2D game is a lot of work for a beginner. So, I'm taking it one line of code at a time.

Thanks for the replies.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS