GDevelopApp / GDevelop-extensions

Repository of behaviors, actions, conditions and expressions to be used in GDevelop for creating games
https://gdevelop.io
MIT License
131 stars 52 forks source link

Box Selector extension #115

Closed BackpackerSlash closed 3 years ago

BackpackerSlash commented 3 years ago

Describtion

Draw a Box with a Shape Painter Object. Place a shape Painter object inside the scenes you want to Draw. "Draw the Shapes relative to the object position on the scene" needs to be unchecked. "Clear the rendered image between each frame" needs to be checked. Selectable Objects should have ther Origin point at the Center. On left click release, if a Box was drawn: For Objects that are more then half inside the drawn Box, the Variable "Selected" of Object is set to 1 For Objects that are NOT more then half inside the box, the Variable "Selected" of Objects is set to 0 A left Click without drawing the box, will unselect all objects, exept the Object under the Cursor, unless the Ctrl key is pressed. Multi-Selection by holding the Ctrl key.

Reserved Variables : Scene Variables: "StartX" / "StartY" / "EndX" / "EndY" / "drawing" Object Variable: "Selected"

remarks: When the Boolean Variables are released to Version 106 of Gdevelop the Object Variable "selected" should be changed to Boolean.

Checklist

Extension file

https://github.com/BackpackerSlash/Box-Selection/blob/main/Box_Selection_Extension.json

Box_Selection_Extension.zip

tristanbob commented 3 years ago

This is a really neat idea! I currently have a lot of other extensions to review, but I certainly want to get to this one. Please be patient. :)

tristanbob commented 3 years ago

Changelog

I have started working on improving this excellent and useful extension. Here are my changes so far:

To do

Video

https://user-images.githubusercontent.com/8879811/122162222-6d27a980-ce30-11eb-84f8-72fb9c37c941.mp4

4ian commented 3 years ago

Very nice! A very interesting extension :)

tristanbob commented 3 years ago

Here is the latest update: https://twitter.com/VictrisGames/status/1405897728639393792

Game example

https://games.gdevelop-app.com/game-ee5646a8-c164-4437-82c2-776b10fcc3ae/index.html

Video

https://user-images.githubusercontent.com/8879811/122578666-54c2b500-d011-11eb-87a3-d7c56d945b4d.mp4

tristanbob commented 3 years ago

Updates

The only remaining questions are:

Any ideas?

Game Example

https://games.gdevelop-app.com/game-7fd1525d-7de2-448e-b939-87f85b5f8f21/index.html

Video

https://user-images.githubusercontent.com/8879811/122630037-452d8580-d07e-11eb-85d4-ed708e711694.mp4

tristanbob commented 3 years ago

Latest updates:

tristanbob commented 3 years ago

Before I finalize this extension, any thoughts on the name of it?

1) Select Objects with Cursor 2) Select Units with Cursor 3) (something else?)

4ian commented 3 years ago

Maybe "Select Units with Cursor"? Usually I would prefer a more generic naming, but for a fairly advanced extension like this it's a good idea to give a name that would "inspire"/convey the feeling of what it can be used for :)

tristanbob commented 3 years ago

I agree, I like "Select units with cursor" better.

Since I am planning on adding "RTS camera controls" next, should I simply call this extension "RTS unit selection"?

Update:

Instead of finishing "RTS unit selection", I started working on "RTS camera controls".

Play here: https://t.co/Nwd0uM4rym

https://twitter.com/VictrisGames/status/1406826544819892234

4ian commented 3 years ago

Since I am planning on adding "RTS camera controls" next, should I simply call this extension "RTS unit selection"?

Yes! Good idea to keep the "RTS" here for both extensions. So let's go for "RTS unit selection" (or "RTS-like unit selection" to emphasis that this could be used for something else? As you prefer)

, I started working on "RTS camera controls".

Looks awesome too! I wonder how the scroll is working on touchscreen, should work more or less out of the box (but you won't have zoom in/out of course and all the rest).

tristanbob commented 3 years ago

Looks awesome too! I wonder how the scroll is working on touchscreen, should work more or less out of the box (but you won't have zoom in/out of course and all the rest).

I'll talk more about this on a new issue for "RTS Camera Movement", but my initial idea is to offer touchscreen camera movement with a three finger drag:

This would leave us with the option to do a two-finger pinch camera zoom, and of course single touch would be used to select units.... but how would you send commands to the units? (perhaps command buttons)

This might be a good time to take a step back to design the entire RTS UI so that we have enough "buttons" to accomplish everything. Here is what I have planned so far:

RTS-like Unit Selection

RTS-like Camera Movement

RTS-like Unit Commands

tristanbob commented 3 years ago

I decided to start posting my builds here so that others can see them and provide feedback.

Version 2.0.0 (work in progress)

Updates:

https://twitter.com/VictrisGames/status/1407564985589403652 https://twitter.com/VictrisGames/status/1407562080165646336

To do:

1) Rename object variables to use "__ExtensionName.VariableName" format 2) Determine if double-clicking ("select all units") actions should be part of this extension

What do you all think about item 2?

Extension file

RTSUnitSelectionExtension_2.0.0.json.zip

Example project files

~~RectangularFloodFill.zip (Ignore the name, I have a lot of stuff going on in this project!)~~

4ian commented 3 years ago

I lost a bit track of the progress on these extensions! Is there anything to review/help on? :)

tristanbob commented 3 years ago

The GOOD news is that I rushed through and implemented a TON of functionality in a short amount of time.

The BAD news is that I haven't taken the time to polish these and get them submitted. I should be able to do this one (now called "RTSUnitSelection") in the next few days.

Thanks for the reminder!

tristanbob commented 3 years ago

Update: I'm still working on this and trying to think bigger than my own RTS project. For instance, I am adding conditions "is selected", "is preselected" and actions "mark selected", "mark preselected". This will enable people to setup their own methods and keybindings for selecting objects. For instance:

Condition: "F2" is pressed
Condition: TriggerOnce
Action: Mark "MyObjects" as Selected
tristanbob commented 3 years ago

Version 2.2.0

Play here

https://games.gdevelop-app.com/game-cc0238eb-a8a8-41f6-96e0-91f5209b951a/index.html

Extension file

RTSUnitSelection_Extension_2.2.0.json.zip

Project files

RectangularFloodFill_SourceFiles_2.2.0.zip (Ignore the name, these are the right files)

Video

https://user-images.githubusercontent.com/8879811/126055980-a0dbedbd-5c1c-4ee4-aa91-67f62d903ef0.mp4

tristanbob commented 3 years ago

@BackpackerSlash since I started this from your template, what do you think of the current state of the extension?

I'm ready for this extension to be reviewed and looking forward to any suggestions for improvement.

tristanbob commented 3 years ago

@4ian (and team) this extension is ready for review. FYI - I am about to go on vacation for about a week.

tristanbob commented 3 years ago

Hold on reviewing this. I decided to make this extension more modular and also have more helper functions. I hope to post the update tomorrow.

tristanbob commented 3 years ago

Version 2.3.0

Extension file

RTSUnitSelection_Extension_2.3.0.json.zip

Playable game

https://games.gdevelop-app.com/game-940922ef-f20f-4729-9692-f2ab0afa3815/index.html

Project folder

RectangularFloodFill_SourceFiles_2.3.0.zip

Bouh commented 3 years ago

Looking really good!

What you think of:

tristanbob commented 3 years ago

Looking really good!

Thank you, and thank you for the review.

  • The sentence for RTSUnitSelection is Select _PARAM1_ with _PARAM7_ mouse button (or touch). Draw a selection box using _PARAM2_ on Layer: _PARAM3_ with Z order: _PARAM4_. Hold _PARAM5_ to add units and _PARAM6_ to remove units. As it's an action Select forward that objects will be selected (or it's only me thinking about that). What do you think of Allow to select... or Perform object picking by selecting ...

Sure, I have changed it to "Allow player to select PARAM1 with PARAM7 mouse button (or touch)..."

  • The description is fine, long but fine, it can be reduced? Requirements, Default controls, and new conditions/actions/expressions are minimal things. I think types and variables names are not useful, the extensions ideas is to hide these complexities. Tips are good šŸ‘

I removed variables and a few other lines. How does it look now?

  • The extension should works in theory with object group in input, did you tried?

Yes, my example uses an object group called "VisionUnits".

  • No periods are required to the end of the sentences in the event sheet. image

I have removed periods like that one.

  • In AssignUnitID there is a repeat loop for Objects, the red comment from RTSUnitSelection about object picking is welcomed to understand why this loop exist. Same for TotalSelectedUnits and others you did it in RTSControlGroups.

I have added that comment on the instances of ForEach() you mentioned.

  • Help link is broken

Try it now.

  • In Author we use handle, tags or names, we don't use URLs. This name will be show in the future to credit users on the extension list.

I changed it to: "Slash, Tristan Rhodes (@VictrisGames)"

Version 2.3.1

Extension file

RTSUnitSelection_Extension_2.3.1.json.zip

Bouh commented 3 years ago

Thx! Added in https://github.com/GDevelopApp/GDevelop-extensions/commit/d6ff2aeb68f0b03465b8e47671e022df1a2a8e9f I've updated to 2.3.2, I've removed parenthesis in author name and simplified it to Slash, Tristan Rhodes, @VictrisGames Even if two last authors is you this format is better for parsing it, and to a better visual for a future marketplace.

4ian commented 3 years ago

Awesome! So great to see this popping in the extensions library šŸš€ Thanks both! šŸ™Œ