Minor programming task

Minor programming task

Postby Sauer2 » 08 Jan 2012, 13:49

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
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 08 Jan 2012, 14:00

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. ;)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 15:31

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.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 08 Jan 2012, 15:38

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! :)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 15:52

Edward_Lii {l Wrote}:Good luck! :)

Thanks :)
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 17:57

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.
Attachments
LevelEditor.h
contains the declaration only
(8.74 KiB) Downloaded 274 times
LevelEditor.cpp
contains the assignment and two changes in drawing and adding an item
(80.04 KiB) Downloaded 272 times
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 08 Jan 2012, 18:20

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. ;)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 18:37

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.
Attachments
LevelEditor.h
(8.8 KiB) Downloaded 268 times
LevelEditor.cpp
(80.06 KiB) Downloaded 408 times
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 08 Jan 2012, 18:59

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)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 19:02

OK, thank you.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 22:04

Hi,

i have a question about 'Addons'. Are these just the maps and themes or does this also cover scripting/plugin functionality?
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby MCMic » 08 Jan 2012, 22:08

Only levels and themes so far. (and level packs)
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: Minor programming task

Postby Sauer2 » 08 Jan 2012, 23:30

OK, I see.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby acme_pjz » 09 Jan 2012, 14:19

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 :)
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: Minor programming task

Postby Sauer2 » 09 Jan 2012, 15:49

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.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 09 Jan 2012, 16:49

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
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 09 Jan 2012, 16:56

Nope, that's not me.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 09 Jan 2012, 17:14

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
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby MCMic » 09 Jan 2012, 17:19

Adding joystick support is a great and easy things to implement IMO
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: Minor programming task

Postby Sauer2 » 09 Jan 2012, 18:00

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 ;)
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Sauer2 » 09 Jan 2012, 18:22

@Edward Lii: You mean, at the moment you can't uninstall themes and levelpacks, did I get that right?
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 09 Jan 2012, 18:26

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. ;)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 09 Jan 2012, 23:31

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
Attachments
Addons.h
(3.85 KiB) Downloaded 273 times
Addons.cpp
(17.03 KiB) Downloaded 280 times
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Minor programming task

Postby Edward_Lii » 10 Jan 2012, 16:30

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. :)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Minor programming task

Postby Sauer2 » 10 Jan 2012, 18:47

No problem at all. Also, from the source i learn a lot, for example, how it's possible to make a GUI in SDL.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Who is online

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