Creating a Game in MATLAB: How to Get Started

  • Context: MATLAB 
  • Thread starter Thread starter khurram usman
  • Start date Start date
  • Tags Tags
    Game Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 12K views
khurram usman
Messages
86
Reaction score
0
i am doing a project from my introductory CS course. i am to make game available online by the name of air transporter. (if possible do check it out online before giving me any ideasa. http://www.physicsgames.net/game/Air_Transporter.html) frankly speaking i do not know all the ropes of matlab. i just want to ask that how should i get started. what functions should i make first? and an important one: i used to move a rectangle using the mouse user input during my labs. but how am i supposed to move a helicopter. i mean should i first introduce an animated image using the 'image' command, assign it a handle and then set it the same way or is there any other suitable method.
thanks for any help.
 
Physics news on Phys.org
id do an OO design where I identify the objects of the game. In this case you have a helicopter and some objects on the ground and some scenery.

then do a top-down outline:
1) initialize game variables (read previous state if any)
2) while loop to:
2.1) read keyboard characters
2.2) dispatch based on keyboard char to routine
3) end of game closeout (save state...)

then make a routine to handle each keyboard command

then make lower level routines to:
- draw an object anywhere you want it. The object could be an image that you place on your graphical canvas.
- read the keyboard and return a command code
- ...MATLAB is really good at data manipulation and data analysis but not so good as a general purpose language
and so ou have not get the performance you want in your game.

Also, you do need to look at a couple of things in MATLAB before proceeding:
1) is there a function to return a single character from the keyboard that doesn't block until the RETURN key is typed.
2) Can you get a canvas and draw on it (ie does it have drawing functions )
 
Last edited: