Can i write a modern/good game without using actors/sprites - libgdx

I have got one sily question. I write a game in libgdx. But my friend always use actors and sprites. But i dont use this class. In all parts or elements of game i extends Sprite. Then i use a array list for using to save elements.
I write game like that: reading input, update, check collision and render. Its ok or not ?

There is no fixed way to go from A to B in programming. I have made a couple of good functioning games without the use of the stage and sprite class. These classes just help you get things done quicker. So yes you can write good games without the use of actors/sprites. It is even possible to write good games without the use of OpenGL or DirectX and create your own graphics library, but why should we? If you know what Scene2D and the sprite class can do for you it is kinda ignorant to leave them aside if they can help you.
It often takes little time to learn a certain library/extension. Once we know how to use it there will be profit for life.

Related

Is Scene2d the best approach for creating a tetris like game using libgdx?

I would like to know if using Scene2d is the best approach for creating a tetris like game using libgdx ?
If yes, what's the approach ? each block is an actor ?
How can I achieve this easily ?
Well that's a bit of a broad question for this kind of format isn't it? :-) I'll try and answer anyway - to get your tetris game going (without much knowledge of libgdx), just take apart & understand an existing example! Download https://github.com/jmillikan/gdx-tetris and have a play around with it, you'll figure out the best fitting approach to execute your specific idea soon enough. Happy coding :-).
For simple games, like Tetris, you don't need to use something as complicated as Scene2d. Instead, just use a 2 dimensional array that represents the board.
board[x][y]=0 //Empty
board[x2][y2]=1 //Filled (or give each block an id)
The draw your screen with a spritebatch.

Beginner need some advice how to write code in AS3

I'm a beginner in programming world, never touch any programming language before. But last 3 days I decide to try make a flash game, I looked some tutorial about AS3, try it, yes I understand a little bit. But I'm still confused about this:
How do I know or to decide what codes I write first, what next? example: I want to add a hero, then a enemy, then a tiles, then a background, event listener.
Is it okay if I write code randomly, example: first I add enemy, then add tiles, add background, then add hero, etc?
What is the best way to completely learn all AS3 codes, especially about flash game dev?
I'm now in frustration mode, so I decide to learn from you all who have mastered AS3.
Check out this guide by Michael James Williams. I was in the same situation as you, and that guide helped me a lot. It goes through a lot of the basics and does a good job of explaining each step.
To answer some of your questions, the order in which you code stuff doesn't matter too much. You can always go back and adjust your old code, and you'll definitely end up doing that at some point.
For learning AS3 syntax, just look through some examples and tutorials, and don't be afraid to read the official AS3 docs. They might be intimidating at first, but once you start learning some of the terminology, they're very helpful.
you can try some video tutorials like these
http://www.lynda.com/ActionScript-tutorials/AS3-language-fundamentals/123492/129625-4.html
http://www.lynda.com/Flash-tutorials/Building-Flash-Games-Starling/98951-2.html?srchtrk=index:1%0Alinktypeid:2%0Aq:flash%2Bgames%0Apage:1%0As:relevance%0Asa:true%0Aproducttypeid:2
If you're frustrated NOW, are you sure that you're ready to invest a couple of YEARS in becoming half-good with Actionscript? You'll have to like learning from your mistakes (an excellent way to learn, actually), because you will make thousands of them and they will cost you thousands of hours!
Do NOT write 'randomly' unless you want to greatly lengthen your time to mastery. Everything you do should have a purpose. I would start (if I were starting again) by giving myself a series of the smallest challenges: make an object appear; make it disappear; make it appear in one second from now; make it appear when I tap a key or click my mouse; make it move across the screen; make it move back; make it follow my mouse... etc.
There are many hundreds of basic programmatic elements like these that will add to your growing grasp of logic, data-structures and language. There are usually many ways to accomplish the same task -- learn and practice all of them.
Luckily, the Internet is full of good tutorials and references to Actionscript, and some decent forums like this one where you can get help.
I know this is king of old but someone might still find this useful.
I think that if you are serious about game development and also want to learn some techniques that are independent of the platform (Flash/AS3 in this case) you should use a framework.
For Flash the best game framework is the Starling along with Feather for UI.
They run on Stage3D which means that run on the GPU not the CPU which make them very fast.
With Starling you can also create mobile games that run in AIR so I think it really is something to consider.
On hsharma.com you can find a free video tutorial that goes through everything you need to know to get starting with game development so it should answer the question on how to create enemies, backgrounds, etc.
Hope this helps someone.

ActionScript 3 movieclip with interchangeable images

I'm creating a game using Flash Develop and ActionScript 3.0 and I can't figure out how to make a "Character Creation" menu, in the sense that, I want to animate a movieclip full of images (head, torso, arms, etc.) and then change out any image with another.
So I'd like players to be able to choose what kind of sunglasses they want their character to have, for example, and the different sunglasses will keep the animation that I made with the original ones.
From what I know so far I can export a movie clip as a .swf and use it as such, but how do I change out images and keep the animation?
Any suggestions are greatly appreciated.
Thanks!
I don't know how much actionscript you know.. but if you just want an idea how to do it and not the whole thing in code...
I would personally make different movie clips for the different parts of the body that can be changed and then change frames in that move clip. For example one movie clip with different hairstyles, one with (sun)glasses and so on.. and then just go to then next frame in the "hairMC" to change the hairstyle.
The way I'd do it is to create MovieClips that all implement the same Interface and then have other MC's higher up that know how to use the particular Interface. For example, if you had an IArm, it might know how to swing and how to grasp (and it might grasp by using an IHand). A fat ITorso might attach the arms at a different spot than a thin one.
And your Character might have an IHead, ITorso, etc. When you created a Character, you could either pass in these components via the constructor (I'm not a big fan of constructor arguments for Views, but it's one way to do this), or you can expose setters on your Character that allow you to set these properties one at a time.
This gives you tremendous flexibility in how to put your character together--none of the pieces know precisely how the others are put together, but the methods they need to operate on are in place, so you can put in any implementation you can think of.

Actionscript without display list (update/draw loop)

I've been working with several different programming languages recently, and I've come to the conclusion that I don't really like the display list in Actionscript. I would much rather have an update/draw loop and draw and manage everything manually like in XNA (C#).
What I do like in actionscript is the ease of use of events, movieclips animations and vector graphics.
What are the possibillites for this?
I would really like to be able to use animated movieclips, but I think that would be impossible without the display list, so I could settle with writing my own animation system with spritesheets.
Rewriting the entire event system isn't something I look forward to though.
Are there any (molehill) frameworks that work without the display list?
You can do something similar by creating a Bitmap with the same size as the stage, attaching it to the stage as a child and using it like a "screen", by blitting your graphics on it every frame (on ENTER_FRAME event). I think it's even mentioned somewhere in the official Adobe documentation, as a method of efficiently animating a large number of objects.
I would advise you to muster up the courage and let go of C# when programming in ActionScript. As Bjarne Stroustrup wisely said in his book The C++ Programming Language:
...applying techniques effective in one language to another typically
leads to awkward, poorly performing, and hard-to-maintain code. Such
code is also most frustrating to write because every line of code and
every compiler error message reminds the programmer that the language
used differs from 'the old language.' You can write in the style of
[another language], but doing so is neither pleasant nor economical in a language
with a different philosophy.
I think that applies very well to the question you're asking here.

Class organization: Function internal or external

I am creating a side scrolling game in Flash (as3) and trying to keep things organized and clean.
Ive created a "Level" class that gets all the level data, player data, and creates all the terrain objects and the player object. Its starting to get messy because im handlng all of the functions for player collision checks and player movement, terrain movement, sound starting and stopping, enemies, and more, all in this class. Is this normal? Or is there a better way to organize things to keep them separate, but still allow them to interact with each other.
I have a player class, and terrain class, and enemy class and etc. but there is not much going on inside them.
Thanks/
Sounds like it's time to take a look at how you can break up your level class and move some of that functionality to other classes. What you're describing happens all the time, so don't worry - it just means it's time to reorganize a little.
You might consider taking you player collision for example, and moving that out to a Physics class. You can set up a static function that allows you to pass in two DisplayObjects, and then tests for collisions between the two.
For sounds, you might consider a singleton class like a SoundManager, that holds onto all of your sounds in an array or dictionary, and then have your other classes play sounds through a function like playSound(soundName:String):void on SoundManager.
Hopefully that gives you a start. Feel free to ask if you need more details. It also might help if you post some of your code. Good luck with it!
Without getting too much into object-oriented design principles here, my advice would be to ask yourself "What belongs in a class named X".
So for example, it sounds like the Level class should keep track of the players, enemies, and terrain on that... well, level (perhaps map or stage might be a better name?). But it doesn't need to do all the work for those objects; many of the functions that do the work for movement, collisions, sound, etc. can be moved to those other classes. Then the Level becomes an orchestrator; kind of like a conductor leading the music (but not actually playing the violins, horns, etc.).
Also, it sounds like players, terrain, and enemies have quite a lot in common. For example, they all need movement and collision handling. You may be able to create a parent class (say GameObject) and have the Player, Terrain, and Enemy classes extend from that. This kind of polymorphism can be very helpful for taking care of common functionality.