Welcome to DSGM! Object Orientation: 6 Examples

Learn to use DS Game Maker by Example.

Welcome to DSGM! Object Orientation: 6 Examples

Postby jadaradix » December 30th, 2010, 12:57 pm

Here is an explanation of the object orientation used in DSGM:

Games created in DS Game Maker take place in different rooms (rooms are flat/2D, not 3D, but might contain 3D-looking isometric graphics). In these rooms you plot objects, each of which is responsible for its own behaviour in the game. Typical objects are walls, moving enemies, buttons or the player. Objects have events, and in each event, a list of actions which are executed when the event is triggered. For example, in a 'collision event' with monster objects, the player would die. The actions for that would be to reset the score and show a 'death' screen.

In designing games with DS Game Maker, objects are the most important element. Each object usually has a sprite, which is effecitvely its displayed image. If the object does not have a sprite, it is simply just invisible to the player, but its events continue to execute as normal in the room. A sprite is sometimes just one image (like a static ball), but often it is animated, such that it contains multiple frames that play after one another (like a walking man). Whilst the game is running, you can change the sprite of any object. For example, the character appears differently when walking left or right.

During the game, things will happen to objects: events. There are many different events available in DS Game Maker, such as collision events with other objects or input from the player. As previously mentioned, each event has a list of actions which are executed when the event is triggered. Actions are things like 'Set Score', 'Play Sound' or 'Go to Room'.

Instancing is also an important concept in DS Game Maker. You can plot more than one instance of any object in a room. This is crucial for many games so that you can create just 1 'wall' or 'enemy' object but plot it many times within the room. You do not have to create multiple wall objects with the same behaviour. You can create and destroy instances of objects whilst the game is running. For example, when a bullet collides with an enemy, you can destroy that instance of the enemy object, and create another instance of the enemy object at a random position.

Rooms in DS Game Maker have 2 backgrounds (one for each screen). The background is displayed behind any plotted objects (and any text drawn by actions in objects). Generally, significantly different pieces of gameplay are separated into different rooms, such that you would have different rooms for the game menu, credits screen, and a different room for each level.

6 Examples

1 - D-Pad Movement.dsgm
1 - D-Pad Movement
(2.27 KiB) Downloaded 2916 times


2 - Stylus Movement.dsgm
2 - Stylus Movement
(2.25 KiB) Downloaded 1435 times


3 - Collectables.dsgm
3 - Collectables
(2.69 KiB) Downloaded 5239 times


4 - Creation.dsgm
4 - Creation
(1.41 KiB) Downloaded 1074 times


5 - Horizontal Shooting.dsgm
5 - Horizontal Shooting
(6.74 KiB) Downloaded 1027 times


6 - Velocity.dsgm
6 - Velocity
(2.42 KiB) Downloaded 1042 times


Using the Examples

(1) Download an example, open it, and understand how it works, and importantly - why. If you don't understand, ask here.
(2) Play the game to see if it does what you thought it would, according to the actions used.
(3) Re-create the game from scratch without referring back to the example, to prove you know how it works.

The examples are designed so that you work from 1 to 6.

You can ask any questions in this topic, as well as post your games where you use these examples, or further examples to be added! You will be credited for good examples that you post.
jadaradix
Site Admin
 
Posts: 895
Joined: December 30th, 2010, 3:23 am
Location: United Kingdom

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby jace » December 31st, 2010, 1:37 pm

Please could you explain to me the use of DBAS: [VX]/[VY]

Is it like the step event of [X]/[Y]?
jace
 
Posts: 90
Joined: December 31st, 2010, 12:50 pm

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Thungbard » December 31st, 2010, 2:41 pm

from what I've been able to figure out so far is:

[X]/[Y] appear to be the coordinates of the object you're putting code into
[VX]/[VY] appear to be the momentum of the object

Examples:
if you set [VX] to a positive number, the object will move to the right each step by that many pixels, forever.
if you set [X] to a number, the object will jump to the x coordinate.
Thungbard
 
Posts: 300
Joined: December 30th, 2010, 8:09 pm
Location: Canada

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby jadaradix » December 31st, 2010, 2:57 pm

Yes; the V is for velocity (speed in a given direction).
jadaradix
Site Admin
 
Posts: 895
Joined: December 30th, 2010, 3:23 am
Location: United Kingdom

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby jace » December 31st, 2010, 2:57 pm

OK, so [VX] = 1 is the same as:
[X] + 1 in the step event

I guess the usefulness of [VX] is that you can use it in events other than the step event, although it is not essential if you know the DBAS/PALib for things such as right click, left click and other events.
jace
 
Posts: 90
Joined: December 31st, 2010, 12:50 pm

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby jadaradix » December 31st, 2010, 3:06 pm

If you wanted to make an object move right when you pressed A, you'd need a variable to communicate between the events. (e.g. set ShouldMoveRight to true, which is checked in the step event to increase the [X]).

The above is solved by velocity.

Also consider if you wanted pacman like movement - you press an arrow key and it moves continually in that direction.
jadaradix
Site Admin
 
Posts: 895
Joined: December 30th, 2010, 3:23 am
Location: United Kingdom

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby nicklausw » July 4th, 2011, 6:24 am

I am so happy the forum exists :D making DS games is a fun experience!
my stuff
pong - sms/gb
sudoku - sega master system

next project - something for the nes, perhaps?[/b]
User avatar
nicklausw
 
Posts: 1037
Joined: May 23rd, 2011, 10:25 pm
Location: The Capital Wasteland

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Sonic The Hedgehog » July 4th, 2011, 8:40 am

It is good Grave digger :lol: :lol: :lol: :lol:
Sonic is gone for good as far as I know.
Or is he?
Spoiler: show
Probably
User avatar
Sonic The Hedgehog
 
Posts: 807
Joined: June 22nd, 2011, 12:26 pm
Location: My happy place

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Nirraic » July 4th, 2011, 2:20 pm

I don't think grave digging works on stickies.
I'm Back :)

Studying: Bachelor of Creative Technology (Audio Engineering and Sound Production)(2014-2015)

Games from the past.
http://dsgamemaker.com/dsgmforum/viewtopic.php?f=14&t=3586#p25711
User avatar
Nirraic
 
Posts: 243
Joined: December 31st, 2010, 10:33 am
Location: Sydney, Australia

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Marklar » July 21st, 2011, 8:31 pm

Total noob here, trying to get started, downloaded the first example in this tutorial and couldn't compile...error came up, said it couldn't compile the game and I should check for errors.

Can someone help me out here?

Thanks!
Marklar
 
Posts: 1
Joined: July 21st, 2011, 8:25 pm

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby DarkRaven118666 » August 14th, 2011, 6:21 am

hey I'm new to DSGM, how come when I try to recreate the first example I get an error saying DSGMPal1_Pal undeclared
DarkRaven118666
 
Posts: 3
Joined: August 14th, 2011, 5:33 am

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Bobbyloujo » August 15th, 2011, 4:41 pm

YoshiInAVoid wrote:In 4.9 there was an option in the tools section called "Reset graphics" I have no idea if James put it in Version 5. See if you can find it, because that will fix it.

Tools > Advanced > Signify Graphics Change

That'll do 'er.
Image
User avatar
Bobbyloujo
Site Admin
 
Posts: 1385
Joined: December 30th, 2010, 8:40 pm
Location: USA

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby DarkRaven118666 » August 20th, 2011, 7:25 am

thanks I got it to work, also i think i had too much colors the first time around
DarkRaven118666
 
Posts: 3
Joined: August 14th, 2011, 5:33 am

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby thelastcaveman » November 6th, 2011, 1:05 am

Just a noob question. I was trying to understand the basic fundamentals of creation and was able to recreate the creation example, however I was unable to understand how to rest the function to be used again and again.

For example: New press create block, New press Delete block, New press create block, etc...
thelastcaveman
 
Posts: 13
Joined: November 4th, 2011, 10:57 pm
Location: In my own world

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby jadaradix » November 10th, 2011, 11:32 pm

So do you have anything to work with? You will need to use a variable to dictate whether a box should be created or destroyed (if I understand you correctly). The issue you might have is that DSGM does all of its work, then refreshes the screen, 60 times a second. So, if you create an object, then delete it later in logic, it will never have been visible.
jadaradix
Site Admin
 
Posts: 895
Joined: December 30th, 2010, 3:23 am
Location: United Kingdom

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby thelastcaveman » November 11th, 2011, 6:44 am

James wrote:So do you have anything to work with? You will need to use a variable to dictate whether a box should be created or destroyed (if I understand you correctly). The issue you might have is that DSGM does all of its work, then refreshes the screen, 60 times a second. So, if you create an object, then delete it later in logic, it will never have been visible.


I didn't try or use variables, never came to mind. That sounds like whats happening because it will work only once, so the object is created and destroyed every 60 seconds i see. So to dictate whether a box should be created or destroyed, i assuming that requires two variables, one for created and one for destroyed?
thelastcaveman
 
Posts: 13
Joined: November 4th, 2011, 10:57 pm
Location: In my own world

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Gizmo » March 29th, 2012, 8:29 am

Can you please tell me how to make a object solid and prevent any other objects from penatrating it.
Gizmo
 
Posts: 1
Joined: March 27th, 2012, 11:09 pm

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby TheMackshun » January 12th, 2013, 11:39 pm

You would need to add collisions to create an object solid. Simply put, it would look something like this.(Logic-Wise)

Code: Select all
If Button Held right && collision not detected{
set x, x + 1
}
Go Check Out Space Destroyer!
viewtopic.php?f=13&t=1876
Info and Demo about my current Rpg, SoulBlaze.
viewtopic.php?f=13&t=2139
Pm me If you need help. I like answering questions. :D
TheMackshun
 
Posts: 212
Joined: January 20th, 2011, 2:56 am

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby py_hacker » February 10th, 2013, 2:52 am

The attachements don't "exist" anymore.
py_hacker
 
Posts: 2
Joined: February 10th, 2013, 1:19 am

Re: Welcome to DSGM! Object Orientation: 6 Examples

Postby Brian.Washechek » May 15th, 2015, 5:44 pm

These examples will aid me in resolving my DSGM error... Could someone send me a working link to download these 6 examples?
User avatar
Brian.Washechek
 
Posts: 284
Joined: April 22nd, 2012, 1:06 am
Location: Casper, Wyoming

Next

Return to Tutorials

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron