Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 18, 2008 disappointed with my code | ||||
---|---|---|---|---|
| ||||
I've got this feeling my code is crap and being written in D, it could be beautiful but I just lack the expertise. But as the code is proprietary I can't just show it to everybody. I really don't like the look of my code :( (1500 lines and will probably go to ~10000) Does anybody have any advice on making your code cleaner, maybe some nice temple code, a few tricks? I know this is a dumb thing to ask, I just got fed up with my code. |
March 18, 2008 Re: disappointed with my code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | Saaa wrote:
> I've got this feeling my code is crap and being written in D, it could be beautiful but I just lack the expertise.
>
> But as the code is proprietary I can't just show it to everybody.
>
> I really don't like the look of my code :(
> (1500 lines and will probably go to ~10000)
>
> Does anybody have any advice on making your code cleaner, maybe some nice temple code, a few tricks?
>
> I know this is a dumb thing to ask, I just got fed up with my code.
Is there really nothing you can give as an example?
Are you writing in a procedural style? OO-style? What is it you don't like about your code? Are you repeating yourself a lot? Do interfaces between components seem to be too confusing or reveal too much implementation detail? Say more about what sorts of problems you have.
--bb
|
March 18, 2008 Re: disappointed with my code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | >
> Is there really nothing you can give as an example?
>
> Are you writing in a procedural style? OO-style? What is it you don't like about your code? Are you repeating yourself a lot? Do interfaces between components seem to be too confusing or reveal too much implementation detail? Say more about what sorts of problems you have.
>
> --bb
No OO, all procedural I think.
Lets just say I write in a C-style in D.
Just recently I included the use of packages.
I think my main problem is that my program goes through a certain amount of
stages (game) but all I could come up with is:
enum { INTRO, LEVEL_1, LEVEL_2,etc}
and everywhere do things like this:
if(stage==LEVEL_1 || stage==LEVEL_2) ...
A lot of times do things need to wait a few iterations, which I solve by adding local variables which count till zero.
I expect that with every 'oh is that possible' reply' my code will be a lot more pleasing.
|
March 18, 2008 Re: disappointed with my code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | Saaa wrote: >> Is there really nothing you can give as an example? >> >> Are you writing in a procedural style? OO-style? What is it you don't like about your code? Are you repeating yourself a lot? Do interfaces between components seem to be too confusing or reveal too much implementation detail? Say more about what sorts of problems you have. >> >> --bb > > No OO, all procedural I think. > Lets just say I write in a C-style in D. > Just recently I included the use of packages. > > I think my main problem is that my program goes through a certain amount of stages (game) but all I could come up with is: > enum { INTRO, LEVEL_1, LEVEL_2,etc} > and everywhere do things like this: > if(stage==LEVEL_1 || stage==LEVEL_2) ... > > A lot of times do things need to wait a few iterations, which I solve by adding local variables which count till zero. > > I expect that with every 'oh is that possible' reply' my code will be a lot more pleasing. Ah, game code. Well I'll let the game programming folks take this one, then. ;-) If you can't show your code, then perhaps the best thing you can do is to read the code of existing games that people have made with D. I know Kenta Cho has code you can look at (http://www.asahi-net.or.jp/~cs8k-cyu/index_e.html). Probably others can suggest examples of what they think are nicely coded games in D. --bb |
March 18, 2008 Re: disappointed with my code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | Most game code I see is OO (I don't get the hint :)
And I don't mean to brag, but this game is a bit more complex than most D
game code I've seen:
Every single moving object has its own artificial intelligence, from
reinforcement learning to spiking neural networks.
I think I just need those simple things like I saw in odefu: main.d
static ~this()
{
SDL_Quit();
DerelictGL.unload();
DerelictSDL.unload();
}
See, I like that code :)
Its just simple things like tese that make code beautiful.
(btw, ABA games is how I got to know D)
>
> Ah, game code. Well I'll let the game programming folks take this one, then. ;-)
>
> If you can't show your code, then perhaps the best thing you can do is to read the code of existing games that people have made with D. I know Kenta Cho has code you can look at (http://www.asahi-net.or.jp/~cs8k-cyu/index_e.html).
>
> Probably others can suggest examples of what they think are nicely coded games in D.
>
> --bb
|
Copyright © 1999-2021 by the D Language Foundation