opengl - Simple game development with Java and LWJGL -



opengl - Simple game development with Java and LWJGL -

of course of study i'm not first 1 develop such game. want become professional game development within in next years. want implement shoot'em game. not first one. developed 1 in turbo pascal 6.0 in 1998. without using oop. game 2nd shoot'em in java, 1st 1 using lwjgl. implemented in 2d.

i want maintain quite simple. there features wanna implement. plan create 10 levels. player has spaceship can move in 4 directions(up, down, left right). ship has double-laser can shoot upwards. ship can moved, don't plan rotation.

one level has several enemies of same kind. enemies spaceships. simple ships move downwards. firing single or double laser bullets. there lasers have min. , max. frequency. want define mathematical function defines how possible have frequency(between min , max).

the ship speed constant within enemy (and level). in later levels enemies gain double or 2,5x speed. enemies in later levels have lasers seek player's ship. plan have 1 enemy in lategame has growing laser bullets.

there no other obstacles within each level. each level has stars background. first want implement static background, later plan create 3 kinds of stars moving @ different speed.

the player's ship's laser single or double damage, depending on if 1 or 2 bullets hit. enemies have hitpoints til die. player ship's has hitpoints til dies.

i want have 2 kinds of explosions(consisting of concetrally spreading ellipses colors yellowish red). little explosion laser hits. , big explosion von ship destruction.

my friend told me there function called 60 times per sec renders graphical objects. think within function draw objects , nil more. of course of study coordinates of ships , lasers change.

so think if should utilize threads or not.

if utilize threads assign every ship appears concurrently 1 thread, , create threads every laser , later dynamic background. in thread wait keyboard input.

of course of study there tradeoff between using threads or not.

using threads leeds realistic parallelism , may necessary have flowing game. avoiding threads lead simpler programming, not regarding concurrent access data. inquire of experienced game developers. utilize threads or not? , if utilize them, conception or not. , why? happy other practical hints.

thank you!

any game can made using single thread plus event listeners. utilize update loop update each object every frame. in simplest terms can loop thread.sleep in although swing timers more advanced technique

int framespersecond=60; double frametime=1000.0/framespersecond; while(running){ for(updatable updatable:updatables){ //should measure frame time since //exactly this. system.nanotime() can used updatable.update(frametime); //depending on graphics library each updatable object may given //the chance render here } renderframe(); //render frame appropriate graphics library thread.sleep(frametime); }

the 1 thing critically must not have many freewheeling threads each doing own thing no co-ordination. impossible write without bugs (and inefficient anyway).

using appropriate numbers of threads

within update loop possible break downwards update independant parts not effect each other. in case can give each part thread (thread pools first-class making process simpler). annother nice utilize threads preparing things needed game not right now; such generating next level.

however, rule multithreading do not have more threads cores. each thread has non trivial overhead 1 time have more threads cores (usually) not increasing execution speed @ all. illustration programme on duel core should have @ 4 threads doing important work. quad core should have @ 8 etc.

java opengl game-engine lwjgl

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -