Page 1 of 1

Minor programming task

PostPosted: 08 Jan 2012, 13:49
by Sauer2
Hi,

i would like to ask, if you have some kind of minor programming task for me to practise C++ and to get in touch with the code structure of Me & My Shadow.

Best regards

Sauer2

Re: Minor programming task

PostPosted: 08 Jan 2012, 14:00
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:i would like to ask, if you have some kind of minor programming task for me to practise C++ and to get in touch with the code structure of Me & My Shadow.

Any contribution is welcome! ;)
MeAndMyShadow is a good game for learning C++ with, it's how I learned it. ;)

You can have a look at the bug/issue tracker for tasks:
http://sourceforge.net/apps/trac/meandmyshadow/report/1

Here's a short list with things you could try:
    * Change order of blocks: tracker (easy)
    * Add an one direction block: discussion (intermediate)

If you've got questions about the code feel free to ask. ;)

Re: Minor programming task

PostPosted: 08 Jan 2012, 15:31
by Sauer2
Hi,

thanks. :)

I guess, I going to start with the order of the blocks, then.
For what I can see, at the moment it is handled by the enumeration GameStates in Globals.h. It seems, the whole game depends on it, so what i would have to do is to create another enumeration like:

{l Code}: {l Select All Code}
enum EditorOrder
{
EDITOR_FIRST=TYPE_START_PLAYER,
EDITOR_SECOND=TYPE_START_SHADOW,
[...]
EDITOR_LAST=TYPE_MAX
};


Also, some parts in LevelEditor.cpp should be changed.
Is this an acceptable solution? Correct me, if i'm wrong.

Re: Minor programming task

PostPosted: 08 Jan 2012, 15:38
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:I guess, I going to start with the order of the blocks, then.
For what I can see, at the moment it is handled by the enumeration GameStates in Globals.h. It seems, the whole game depends on it, so what i would have to do is to create another enumeration like:

The whole game uses the enumeration but isn't 100% dependent of it.
If the order in that enumeration is changed (and the one in Game.cpp) the game will still be the same.

Sauer2 {l Wrote}:Also, some parts in LevelEditor.cpp should be changed.
Is this an acceptable solution? Correct me, if i'm wrong.

This solution looks fine for me, I think it's better than changing the original enum.
It allows more possibilities:
    * easier changing of order
    * possibility to exclude certain blocks. (Not needed though ;) )

You can still use the currentType variable, you'll have to change the parts where the currentObject is drawn, increased or decreased and where the bound checks are done. (<0 || >TYPE_MAX).
Good luck! :)

Re: Minor programming task

PostPosted: 08 Jan 2012, 15:52
by Sauer2
Edward_Lii {l Wrote}:Good luck! :)

Thanks :)

Re: Minor programming task

PostPosted: 08 Jan 2012, 17:57
by Sauer2
OK, it seems to work now.
It's realised with an static array, which belongs to LevelEditor, since I noticed that one can't iterate through an enumeration.

Re: Minor programming task

PostPosted: 08 Jan 2012, 18:20
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:OK, it seems to work now.
It's realised with an static array, which belongs to LevelEditor, since I noticed that one can't iterate through an enumeration.

It looks good, only there's one thing I'm not sure about.
The advantage was that we can easily change the order and/or leave some blocks out.
But this isn't possible due to this line(2.665):
{l Code}: {l Select All Code}
if(currentType>=0 && currentType<TYPE_MAX){

Because if we leave one or more blocks out there would be empty entries in the editorTileOrder, adding some "invisible" blocks while scrolling.

I think you can solve this by adding a static int before the array named something like EDITOR_TILE_MAX.
You can then use that to check the upper bounds and for the declaration of the array:
{l Code}: {l Select All Code}
static const int editorTileOrder[EDITOR_TILE_MAX];

Only one variable (EDITOR_TILE_MAX) and the array have to be changed to remove/add a block.
(BTW the code uses '//' even for multi-line comment. ;) )

Should I make these changes or would you like to do that?

Thanks again for your contributions. ;)

Re: Minor programming task

PostPosted: 08 Jan 2012, 18:37
by Sauer2
I fixed it and it seems to work, but it would be cool if you could take a look on it, because i'm not too sure if the array is to large now.

Re: Minor programming task

PostPosted: 08 Jan 2012, 18:59
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:I fixed it and it seems to work, but it would be cool if you could take a look on it, because i'm not too sure if the array is to large now.

First of all, you don't have to add EDITOR_ORDER_MAX to the array.
I assume you did this because something similar happens with the gameobjects (TYPE_MAX), but that is used as the max.
Since you already have this as a separate static int it isn't needed in the array.

There are a few lines that need to be changed:
{l Code}: {l Select All Code}
currentType++;
if(currentType>=TYPE_MAX){
      currentType=0;
}

Should become:
{l Code}: {l Select All Code}
currentType++;
if(currentType>=EDITOR_ORDER_MAX){
      currentType=0;
}

The same goes for the part where currentType is reduced.

I've fixed it for you and commit the changes, thanks ;) ,
(revision 181)

Re: Minor programming task

PostPosted: 08 Jan 2012, 19:02
by Sauer2
OK, thank you.

Re: Minor programming task

PostPosted: 08 Jan 2012, 22:04
by Sauer2
Hi,

i have a question about 'Addons'. Are these just the maps and themes or does this also cover scripting/plugin functionality?

Re: Minor programming task

PostPosted: 08 Jan 2012, 22:08
by MCMic
Only levels and themes so far. (and level packs)

Re: Minor programming task

PostPosted: 08 Jan 2012, 23:30
by Sauer2
OK, I see.

Re: Minor programming task

PostPosted: 09 Jan 2012, 14:19
by acme_pjz
Hi,

Sauer2 {l Wrote}:Are these just the maps and themes or does this also cover scripting/plugin functionality?


Currently there is no scripting support... If you'd like to add it, then it will be cool :)

Re: Minor programming task

PostPosted: 09 Jan 2012, 15:49
by Sauer2
Not until i have practised C++ much more. :)
Plus, i'm not totally sure, how scripting could be used. I mean, there could be triggers, but at the moment, the possibilities of actions are limited.

Re: Minor programming task

PostPosted: 09 Jan 2012, 16:49
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:Plus, i'm not totally sure, how scripting could be used. I mean, there could be triggers, but at the moment, the possibilities of actions are limited.

I can't think of any use for a scripting in meandmyshadow right now.
But if you look at XMoto, some interesting stuff has been done with scripting.

BTW, I've noticed some new entries in the bug tracker, made by some aapoaapo, is that you by any chance Sauer2?
https://sourceforge.net/apps/trac/meandmyshadow/report/1

Re: Minor programming task

PostPosted: 09 Jan 2012, 16:56
by Sauer2
Nope, that's not me.

Re: Minor programming task

PostPosted: 09 Jan 2012, 17:14
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:Nope, that's not me.

Just checking. ;)

BTW, are you still looking for a minor programming task?
Because I just realized that with the addon manager you can't remove an addon when there's an update for it.
Perhaps you know a solution to this problem, add a button if you like.

@all
There are some newly tickets we should look at:
Compiler warnings: "deprecated conversion from string constant to 'char*'" on Functions.cpp
Several compiler warnings "no newline at end of file" (old compiler)
Request: support keyboards without function-keys

Re: Minor programming task

PostPosted: 09 Jan 2012, 17:19
by MCMic
Adding joystick support is a great and easy things to implement IMO

Re: Minor programming task

PostPosted: 09 Jan 2012, 18:00
by Sauer2
OK, i will take a look at the addon manager and maybe also at the "deprecated string conversion problem".

@MCMic: Maybe it's easy, but i don't have a joystick to test ;)

Re: Minor programming task

PostPosted: 09 Jan 2012, 18:22
by Sauer2
@Edward Lii: You mean, at the moment you can't uninstall themes and levelpacks, did I get that right?

Re: Minor programming task

PostPosted: 09 Jan 2012, 18:26
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:@Edward Lii: You mean, at the moment you can't uninstall themes and levelpacks, did I get that right?

No, not exactly.
The player has a local list with installed addons and the installed version. (installed_addons)
The list with addons from the server is downloaded, if an addon is installed an '*' will be placed behind the name,
if there's an update a '+' will be placed at the end of the name.

There's one button that is used to install/update/remove an addon.
Meaning that if an addon isn't installed the button will say "Install".
If an addon is installed and up to date the button will say "Uninstall".

BUT, if the addon is installed but of an older version it will say "Update".
So if the player wants to remove an addon that has a newer version on the server the player has to update that addon and then remove it.
This problem can be solved by making two buttons, Install/Update and Remove. ;)

Re: Minor programming task

PostPosted: 09 Jan 2012, 23:31
by Sauer2
Hi,

i added an update button in the middle of the button row at the bottom, which is disabled if there is no update.
It would be cool if someone could test the update functionality, because to be honest, i don't know how.

Best regards
Sauer2

Re: Minor programming task

PostPosted: 10 Jan 2012, 16:30
by Edward_Lii
Hello Sauer2,

Sauer2 {l Wrote}:i added an update button in the middle of the button row at the bottom, which is disabled if there is no update.

Thanks, looks good. :)
It's now in revision 187.

One thing I changed is that the update button also hides when disabled.
That's because with our GUI system it's hard to see if a button is enabled or not.

Sauer2 {l Wrote}:It would be cool if someone could test the update functionality, because to be honest, i don't know how.

I tested it and it works fine, you can simply test it by changing a line in the installed_addons file.
{l Code}: {l Select All Code}
entry(levels,Flight,1)

By lowering the installed version an update will be available:
{l Code}: {l Select All Code}
entry(levels,Flight,0)


Thanks again for making the separate update button. :)

Re: Minor programming task

PostPosted: 10 Jan 2012, 18:47
by Sauer2
No problem at all. Also, from the source i learn a lot, for example, how it's possible to make a GUI in SDL.