Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add polygon component #774

Merged
merged 6 commits into from
Oct 24, 2023
Merged

Conversation

trevordilley
Copy link
Contributor

Adds a polygon component so we can draw arbitrary shapes.

Usage example:

kaboom()


// Draw a square the hard way
add([
        polygon([vec2(0,0), vec2(50,0), vec2(50,50), vec2(0,50)]),
	pos(80, 120),
	outline(4),
	area(),
	color(rgb(255,0,0)),
	opacity(0.2),
])

@trevordilley
Copy link
Contributor Author

Oh shoot, doesn't work with colliders correctly...

@trevordilley
Copy link
Contributor Author

Oh lol, that's just how things work.

pts,
})))
},
renderArea(this: GameObj<AnchorComp | PolygonComp>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polygon is supported for collision detection, you can use

return new Polygon(this.pts)

here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh which would automatically make the polygon the default area for collision detection? Nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I've done the thing! I also updated the polygon example to show the collision matching the polygon shape!

@slmjkdbtl
Copy link
Contributor

Thank you! This is very good

@slmjkdbtl slmjkdbtl merged commit c485a3f into replit:master Oct 24, 2023
2 checks passed
@trevordilley
Copy link
Contributor Author

Thanks! First time I've managed to get a PR merged on a OSS project! Pretty exciting for me!

tristanperrow added a commit to tristanperrow/kaboom_fork that referenced this pull request Dec 5, 2023
* Add blockly editor (replit#667)

* add more blocks

* clean

* use kaboom_ prefix

* improve

* stuff

* shadow

* blocks

* kinda make callback work

* add stuff

* stuff

* dynamic add block

* clean

* add hasOutput option

* yes!!!!

* better movement

* improve color

* add add block checks

* misc

* local images

* fix example

* add more icons

* more icons

* kinda fix size

* fix ts

* fix initial resize event

* fix mem leak on resize

* alpha.24

* only import types from types.ts, fix import issue

* prep v3000 beta, update site

* fix ts

* fix site crash

* add icons

* upgrade deps

* update site deps

* add embed editor for articles

* rm unused deps

* gravity() -> setGravity() / getGravity(), more 3000 blog

* support LoadFontOpt

* improve text outline

* text atlas lineJoin

* Fixed testLineCircle (replit#671)

* Improve gamepad support (replit#672)

* Add support for Nintendo's Pro Controller

* Fix mapping for `Joy-Con L+R` gamepad

* Add support for using a single Joy-Con

* Add new accepted values to `GamepadButton` type

* add custom gamepads support

* add xbox360 gamepad

* tmp workaround for correct audio.time() when looped

* rm generic gamepad to fallback to default

* send 0.0 to stick events

* rename dpad buttons

* rm follow()

* revert removing follow()

* fix doc render

* froggy -> bean

* fix get/set cursor

* beta.0

* fix example and blog twitter card

* Fix broken link (replit#677)

* use better gamepad default

* add setCursorLocked()

* add AgentCompOpt to agent() type (replit#685)

* add AgentCompOpt to agent() type

* make opt optional

---------

Co-authored-by: tga <tga@space55.xyz>

* update readme (replit#680)

* update readme

* remove 0.5 doc from misc section

* fix details, add dots and update examples code (replit#679)

* add final dots and update some doc

* fmt and update addLevel example

* repos elements in hover demo

* fix concert demo, and music code example

* fix shooter example music

* add src/app.ts

* adopt app.ts

* fix err in migration guide

* fix objects not falling off platform when not overlapping

* improve drag example

* fix type

* fix ts error

* fix events not running for recursive children

* fix mouse pos

* prevent volumn go below 0

* fix sprite having 0 width height on load

* fix spriteatlas breaking

* cleaning

* fix events not clear when scene switch

* add amount health arg to onHurt / onHeal

* forward kabooom opt to app

* support maxFPS

* beta.4

* update deps

* add 404 to dev server

* Kaboom gamepads (replit#698)

Co-authored-by: tga <tga@space55.xyz>

* rm redundent

* add loadJSON() and getAsset()

* switch to tauri

* use tauri for create-kaboom

* rm unused code

* automatically clean up events registered in comp.add

* add unuse example

* fix tween type, add loop and tween to timer() comp

* tie timer comonent wait with game object

* remove params to timer()

* fix timer references

* mention tauri + rust in create-kaboom readme

* Fix file type in setup.md. (replit#703)

The file type of the horse sound was wrong (png), so i changed it to mp3.

also fixed a typo.

* doc

* add onSceneLeave

* add README to create-kaboom projs

* tauri icon

* fix tiled sprite

* better fix

* replace all object assign to not mutate original opt

* fix anim 0 error

* deal with resize

* fix more sizing issues

* fix letterbox!

* fix letterbox resizing

* fix fulllscreen

* clean

* fix global scale

* rm virtual control

* v3000 stable

* fix onclick

* isTouchscreen typo

* Remove concept tutorials, fix many refs and links (replit#719)

* remove concept tutorials, fix many refs and links

* fix

* update intro screenshots (replit#720)

* add make()

* fix for `debug.inspect` doesn't show the properties box if the area is from a child of a child replit#716 (replit#722)

* bug fix release

* add typing for plugins in `kaboom()` returns (replit#727)

* fix some ts errors, add MergePlugins

* fix mini typo

* mention create-kaboom in setup

* add back legacy endpoints

* fix global scale

* fix: ignore errors from other sources (replit#723)

This e.g. happens with iframes.
Seems to fix replit#466

* Bump tauri from 1.2.4 to 1.2.5 in /src-tauri (replit#710)

Bumps [tauri](https://github.com/tauri-apps/tauri) from 1.2.4 to 1.2.5.
- [Release notes](https://github.com/tauri-apps/tauri/releases)
- [Commits](tauri-apps/tauri@tauri-v1.2.4...tauri-v1.2.5)

---
updated-dependencies:
- dependency-name: tauri
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* dont init draw state until draw phase

* 3000.0.6

* fix vit import

* fix types

* fix some types

* recursively run destroy event to children

* fix ts and drawCircle

* shake() adds up instead of replace

* fix accessing mouse pos in touch events

* fix relateive touch pos

* empty components and plugins with options (replit#730)

* improve ts of plugins

* better plug

* empty comps

* lit generic type fix in kaboom()

* remove unrelated ts-ignore

* fix fixed inheritence

* alternative fixed fix

* version

* update dep

* downgrade puppeteer

* delete unused

* try

* refactor scripts

* update site deps

* Update types.ts (replit#743)

Adds a comment explaining the usage of Texture.free() and it's importance

* doc: fix OffScreenCompOpt.distance default value (replit#738)

The value is actually 200 in [source](https://github.com/replit/kaboom/blob/aa44a62999b6b510c24e317fc76ffc64524e9680/src/kaboom.ts#L3743C1-L3744C1)

* type `GameObjRaw#onAdd` (replit#737)

* Fix kenney assets link (replit#733)

* Expose clamp() math helper (replit#732)

* Expose clamp()

* Add clamp in types.ts

* Bump word-wrap from 1.2.3 to 1.2.5 in /pkgs/matter (replit#751)

Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.5.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](jonschlinkert/word-wrap@1.2.3...1.2.5)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump semver from 6.3.0 to 6.3.1 in /site (replit#749)

Bumps [semver](https://github.com/npm/node-semver) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v6.3.1/CHANGELOG.md)
- [Commits](npm/node-semver@v6.3.0...v6.3.1)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: support pingpong loop for sprite anim (replit#745)

* feat: support pingpong loop for sprite anim

* format: better indents

* fmt

* change default logMax to 10 (replit#736)

* add log time

* deps

* input events on game obj

* workaround

* deps

* clean up, changelog

* fix background audio, expose onHide and onShow events

* tips

* rm dup

* misc fix

* fix debug.timeScale

* fix debug.paused not able to resume

* fix sprite quad not working

* stop audio on error

* SpriteData#width

* fix collide update still running when obj paused

* allow empty add() and make()

* improve err msg

* add audio.stop()

* add Event#clear()

* fix add() without arguments

* fix changelog

* fix typings

* fix debug paused not pausing audio

* add mask() and colored font outline

* naming

* only handle own error

* misc

* update text width immediately

* fix debug ui when scale & size are set (replit#755)

* v3000.1.8

* add fill option

* add kaboomware site

* update deps

* site

* site

* fix view getting cut off, update deps

* fix test code accidentally getting shipped

* fix resize event gets cleared on scene change

* use tex / framebuf binder stack

* fix toImageData flipped

* fix mousepos in fullscreen

* add Color#toHSL()

* fix err

* version

* fix color not working, add confetti example

* fix site

* add draw field to render comps

* rm site

* use gfx.ts

* cleaning

* cleaning, modulizing assets

* fix shader error report

* improve deepeq

* fix moving platform

* Fix emoji display in text (replit#771)

* Fix emoji display in text

* Fix emoji text color

* cleaning

* fmt & improvements

* use overload helper

* fix maxhp

* start adding offscreen canvas

* rm global err hand

* update deps

* misc fix

* Add polygon component (replit#774)

* Initial commit of polygon component. Updates types, adds the logic, and provised a real boring example in examples/

* Fixes a linting issues in examples/polygon.js

* Removes extraneous comment, reorders components to polygon() is first in example

* nit: Fixes newlines in import

* Updates the polygon fn to return a polygon render area, which makes it so that polygons always collide with their shape not a rect

* Use this.pnts instead of just pnts so we can capture any updates to points later

* pass polygon() opts into drawPolygon()

* improve polygon example

* fix loadRoot not working sometimes

* fix error not being logged

* expose velocity

* improve jump example

* v3000.1.17

* add drag

* fix: skip zero-width character render (replit#787)

* update intro inspect img (replit#785)

* fix: err TS2339 (replit#788)

* support anim pingpong without loop

* improve doc

* improve doc

* fix sizing issue with global scale

* Fix puppeteer deprecated warning (replit#791)

* Fix puppeteer deprecated warning

* format

---------

Co-authored-by: tga <tga@space55.xyz>

* Fix example in types.ts (replit#794)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: tga <tga@space55.xyz>
Co-authored-by: Marc Flerackers <mflerackers@gmail.com>
Co-authored-by: Nestor Vera <nestorvera@me.com>
Co-authored-by: Sean <seanrabaut@gmail.com>
Co-authored-by: Danie <lajbelms@gmail.com>
Co-authored-by: kingerious <78227395+MDxWARRIORxOP@users.noreply.github.com>
Co-authored-by: Hayden Mankin <DryCreations@gmail.com>
Co-authored-by: Pelle Johnsen <pelle.johnsen@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: coding398 <55938439+codingMASTER398@users.noreply.github.com>
Co-authored-by: Nami W <1160688+namiwang@users.noreply.github.com>
Co-authored-by: Luiz Bills <luizbills@pm.me>
Co-authored-by: hirnsalat <hirnsalat@users.noreply.github.com>
Co-authored-by: 陆陆侠 <306924625@qq.com>
Co-authored-by: trevordilley <trevor.lee.dilley@gmail.com>
Co-authored-by: Neerajkumar <78979288+Neerajkumarc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants