axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

Improve the default templates (at least the cpp template) #1493

Closed aismann closed 11 months ago

aismann commented 11 months ago

For a better (cpp) template let us find some improvements:

1) Changing class HelloWorldto class HelloWorldScene. 2) Maybe a redesign of the folder structure like on axmol-game-demo

Anything missed there? Everybody proposal is welcome.

iAndyHD3 commented 11 months ago

i suggest the template to be a separate repo so you can clone it separately. command line tool should clone from github too. this would reduce repo size further

halx99 commented 11 months ago

actually code not affect repo size significant. it's binary files which already removed when rebase axmol main repo.

halx99 commented 11 months ago

I think builtin template should as simple as possibile. if there are rich samples need be referenced, just add to related list

aismann commented 11 months ago

I think builtin template should as simple as possibile. if there are rich samples need be referenced, just add to related list

Good point. I close this issue

iAndyHD3 commented 11 months ago

other suggestions: better code to avoid all the #ifdefs or make it more clear. here make a function to return the size so there is just something like

 director->setContentScaleFactor(getScaleFactor());

instead of if/else if/else in main function

rh101 commented 11 months ago

I think builtin template should as simple as possibile. if there are rich samples need be referenced, just add to related list

I completely agree with this, so please don't add anything more to the template. It's just meant to be the minimum amount of files (and code) in order to be the starting point for a project; anything more than that would mean experienced developers have to clean it up before using it, and new developers to Axmol may be overwhelmed by the contents of the new project.

rh101 commented 11 months ago
2. Maybe a redesign of the folder structure like on [axmol-game-demo](https://github.com/paulocoutinhox/axmol-game-demo)

Just one further thing to add, which may be more of an issue for newer developers. That project you linked has some questionable coding practices (such as usage of using namespace in header files), which would cause problems for developers who may not be experienced enough to spot such problems early on. So, while it may look like a good clean demo project, it doesn't necessarily mean it's the right one to be showing new developers.

paulocoutinhox commented 11 months ago

My suggestions:

I agree with not filling the template with new things, but everything I'm putting in is what any user will have to do in a real project.

aismann commented 11 months ago

I want rename the files like below: => Is this ok for you? image

paulocoutinhox commented 11 months ago

Nice :) Too much better.

aismann commented 11 months ago

First shot: image

paulocoutinhox commented 11 months ago

??? what is this?

aismann commented 11 months ago

maybe this one is better: image

paulocoutinhox commented 11 months ago

In my opinion, the AXMOL is better, because it is more generic and is not related to what template was used. More generic is better.

iAndyHD3 commented 11 months ago

Further improvements:

Error label that appears when the Content folder can not be found.

At the moment when the Content folder can't be located the screen is empty and just black. The real problem is that when compiling in release the console does not appear by default (does it in Debug?), the user doesn't know what is going on. Ideally the label would use a system font (like this?)

auto label = Label::createWithSystemFont("Content folder could not be found", "Arial", 24)

It works correctly on windows, but I'm unsure about other platforms.

Check for nullptr directly at the creation of nodes

this:

auto sprite = Sprite::create("HelloWorld.png"sv);
if(sprite != nullptr)
{}

can be rewritten much cleaner as:

if (auto sprite = Sprite::create("HelloWorld.png"sv))
{}

There are a few improvements by using this syntax

You might say it is not important, but the template code is the first interaction with the engine for many new users. Therefore it should truly be as good as possible

rh101 commented 11 months ago
* Put all comments in a single line and lowercased, because every comment has one pattern (The sentences are strange and broken, so someone commented anyway)

I respectfully disagree with this suggestion. Yes, the current comments are not "strange", but the more appropriate fix would be to follow convention and the proper structure of a written language, which is to indicate the start of a sentence by capitalizing the first letter of the first word. Having a lower-case word at the start of a sentence implies that it is a continuation of sentence above it. The only time a lower-case letter would make sense is if it were some camel-case identifier in the code that is being used at the start of that sentence in the comment etc.

* Don't break the code, put the full line in a single line, like this: https://github.com/axmolengine/axmol/blob/dev/templates/cpp-template-default/Source/AppDelegate.cpp#L86C9-L87

An assumption cannot be made that everyone uses large/wide screens while programming, so using the example you linked, that would actually slow down the ability absorb what is on that screen, since it's breaking the flow of reading the information by forcing the reader to scroll right. At the moment, the engine has a clang-format with a line width limit of 120, which is reasonable enough, and it only applies to engine source code.

Once a new project is created from the template, what format the developer wants to use for their project is entirely up to them. This would be enabled by implementing your suggestion of having default clang-format, editorconfig and such files in that template that the developer can adjust to suite their style and coding conventions.

aismann commented 11 months ago

This is the new "view" on VisualStudio for 'HelloWorld' Maybe 'AxmolLogo.png' is better? image New "HelloWorld" look: image

@halx99 is this ok for you?

rh101 commented 11 months ago

This is the new "view" on VisualStudio

I don't understand the context. What exactly has changed?

aismann commented 11 months ago

This is the new "view" on VisualStudio

I don't understand the context. What exactly has changed?

Its the summery of all changes on file names and VS project names

rh101 commented 11 months ago

Its the summery of all changes on file names and VS project names

I don't quite understand the "VS project names" change. Do you mean that you want to call the generated project "CPPTemplate" regardless of what name is passed to the axmol new .... command? Or, do you mean you want to change the "cpp-template-default" to "CPPTemplate" in the engine source?

paulocoutinhox commented 11 months ago

Why not use more generic names, like Logo.png instead of Axmol.png. I think that more generic is better.

aismann commented 11 months ago

Its the summery of all changes on file names and VS project names

I don't quite understand the "VS project names" change. Do you mean that you want to call the generated project "CPPTemplate" regardless of what name is passed to the axmol new .... command? Or, do you mean you want to change the "cpp-template-default" to "CPPTemplate" in the engine source?

axmol new .... makes allways the name which is part of the command

'CPPTemplate' (replacing HelloCpp;) is created with CMakeList.txt:

    # add cpp-template-default into project(axmol) for tmp test
    add_test_target(CPPTemplate ${_AX_ROOT}/templates/cpp-template-default ) 
rh101 commented 11 months ago

axmol new .... makes allways the name which is part of the command

'CPPTemplate' is created with CMakeList.txt:

    # add cpp-template-default into project(axmol) for tmp test
    add_test_target(CPPTemplate ${_AX_ROOT}/templates/cpp-template-default ) 

Oh! I understand what you mean now.

aismann commented 11 months ago

axmol new .... makes allways the name which is part of the command 'CPPTemplate' is created with CMakeList.txt:

    # add cpp-template-default into project(axmol) for tmp test
    add_test_target(CPPTemplate ${_AX_ROOT}/templates/cpp-template-default ) 

Oh! I understand what you mean now.

I need the 'OK' from @halx99 for further work

halx99 commented 11 months ago

why change to CppTemplate, the HelloCpp is fine

aismann commented 11 months ago

why change to CppTemplate, the HelloCpp is fine

1) In my "first time" with engine-x I wondered where the HelloCpp comes from. => Thats clearer now for beginnner (in my point of view)

2) Hello World is still there as label

@halx99 If you want HelloCpp again, I'll change it again

halx99 commented 11 months ago

at least, the lua/cpp templates can be merge into a single template.

aismann commented 11 months ago

at least, the lua/cpp templates can be merge into a single template.

Maybe. I think its not so easy (different CMakeList.txt, and some more different) => Im not so familiar with Lua.

@halx99 First step for this is merge the current PR for CPP. Maybe another more Lua expert can than start to make a single template for CPP/Lua. What are you mean? For Lua Im out.

paulocoutinhox commented 11 months ago

i put my comments on pr

aismann commented 11 months ago

closed