| |
Game Maker Engines, One you've always wanted...
Baroque |
|


Group: Members
Posts: 817
Member No.: 6076
Joined: 11-March 09
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Razz @ Mar 12 2009, 01:19 AM) | | your coding is so messy it's not even funny. |
You're kidding, right? It's fine and perfectly legible. The semicolons are optional, but they'd be good practice. It's certainly not "OH MY GOD THAT IS NOT EVEN FUNNY."
The messiness is in code efficiency, not in format.
Here is my optimization, which improves performance as well as format:
| CODE | // This can be used as a script // Or copied into the sprite's Step condition.
// Example By [[[--___-Kremling-___--]]], hope this helped : ) // Formatted / optimized by Baroque
// Variables for Movement var l,r; // Definition
l = keyboard_check(vk_left); r = keyboard_check(vk_right); lr = keyboard_check_released(vk_left); rr = keyboard_check_released(vk_right);
// Movement Code // If there were a momentum variable, this would be more efficient ... // But this is an animation tutorial, not an engine tutorial.
self.move = 0; // This will stay 0 if there's no input. if (l && !r) { // Left, but not right x-=4; self.move = 1; // Now moving; checks for this later } else if (r && !l){ // Right, but not left x+=4; self.move = 1; // Now moving; checks for this later }
// Image Animation Code
// image_index and image_speed are built-in variables. // image_index is the number of the subsprite contained in the current Sprite. // image_speed is how quickly GameMaker animates this Sprite. // Both may be set directly without apparent incident.
if (self.move){ // If moving image_speed = 0.3; // Image will animate } else { // Otherwise image_speed = 0; // Stop animation image_index = 0; // And reset it to standing frame }
if (l && !r) { // Left, and not right image_xscale = -1; // Faces left } if (r && !l) { // Right, and not left image_xscale = 1; // Faces right }
if (self.move && image_index >= 2) { // While moving, sprite has reached maximal frame image_index = 0; // Restart animation } |
--------------------
  (DA needs update) | Clean FA | Why I Cut QuotesYou see things, and you ask, 'Why?' But I dream things that never were, and I ask, 'Why not?' | QUOTE (Ryo) | its the correct form of to.........lemme run it down for ya
to is used when your talking about the number. good way to remember this: to has to letters
too is used when your talkin about actions in stuff.
two is used when your talking about places and locations |
|
|
|
blackcat12 |
|

I see you
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif)

Group: Members
Posts: 678
Member No.: 5144
Joined: 6-April 08
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
One GM engine that I've always been after is a beat-em-up engine. It would be cool to have a small beat-em-up engine that lets you punch and kick enemies to send them flying, while retaining your momentum as you move across the screen. (Think a simplified version of Astro Boy: Omega Factor) Hope that's not too much to ask! (If it is, feel free to tone it down a bit)
--------------------
        REF Slightly Obsolete Ref
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
[ Script Execution time: 0.0634 ] [ 15 queries used ] [ GZIP Enabled ] [ Server Load: 0.65 ]
| |