Add grid snapping

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
Nic0Nic0Nii 9 months ago
parent 50562dbf5c
commit f5588d053b
  1. 12
      TiledCollisionEditor.data
  2. 2
      TiledCollisionEditor.js
  3. BIN
      TiledCollisionEditor.wasm
  4. 29
      TiledCollisionEditor/main.cpp
  5. 1
      TiledCollisionEditor/pixelGameEngine.h
  6. BIN
      assets/font3.png

@ -956,4 +956,14 @@ wH
<?xpacket end="w"?>'Vk¹bKGD—?Ÿ pHYsÃÃÇo¨dtIMEè *)¡þ‰ëIDATxÚí\Ý–† ,OïÿÊíU紮ƒZ›WûmI¢Ãø³m`9oe{xyƒŒR<<EFBFBD>Õë¼ëÿÞÎ<EFBFBD>
s@Q}Ÿ>ÊèÙ†Žµ³Ïó<÷}ß‘z×»–çšì{›¥ö¯bD—ŽeÆÀ·fÖ^•¬™h®:×sé« ü¶mÛn@¯r÷Ù٪ߓ_w¨T?Úé¯Ð3Æ–¨Zå³ôK³¶ºxâ7Š5²0âúµwf<EFBFBD>Ð<EFBFBD>ü(Ú—1Œûÿë÷z3;);æg>Eö,ëDb~=OBû,ù½~ù’Ú¯üª@'­¾ô¼–Ûú­M~¤>ðf3äýnû­nÕê&Ù¿£®-«=Œvf€Õà.èG%ËÒ¬nDzaÉ$²Ú“<EFBFBD>jjß–toñ'G]9K‹[õ„)lX;ÎÊðeLhžßC‘„’Ò¨ ÷•ÃvËÙa&[®5½Ja¹.«å>©0ŒñF=ƒ<EFBFBD>dšü–Û§ }šÖпf 3³•'¡ý•×¾2#Ï·¸4-<EFBFBD>öäù¨×è¼(åPy­Yªy$m!Kk¿ê¹´x²Òïl€]<EFBFBD>ïÉ‹®ôþçÕï@-g¥|سGó¯üÃb<EFBFBD>¬Îg î^.Ë
]KÅæ[þÞÛµäáitfXb`†•3äÕd‡E?æf ú~ÑrÁ™yóÛx€<EFBFBD>yæ÷Ü+æjô©5϶¶ù>ª[+_¶Èï b´ÿ3õÿÊ[óüì<ݶ´¼ýÍÈ“Y<@Ëk 8 <EFBFBD>¡[%oÏØ/`•éá9¼zDùƒh)SÜÍÀ˜ÓÂ3™¨Û#›µdl-+O<EFBFBD>¾ÙD‹„¦Ñö36cŒì›R§y‘ÆKs—¿bª§ùÒôc \´o¬uKÆì<EFBFBD>×ß¿+<EFBFBD>µËš]L™^°œW>©AZ¶žGÝ>R?2°¿Î¯9å yºeSÊ:JíW<EFBFBD>áÛØÿ? í³<EFBFBD>g´1fžíGåOCû3<EFBFBD>fæ ²éáUÓXZªç>ñ‘ðÜû} cg•<EFBFBD>ÆkÏ®œ(˜¬Á^êÄwöXö"DwyÜ~„ÔN{wö¥FºFdp{–Ïâf…Æ–GkeThýëw±(ÍZï÷ „tmË=ÍAH¦€q&¹ÕºÝÄ•ç{brô8ƒΤ—µx‹pèf<EFBFBD>ãûÖó¿²íÖ=ï™Öó†t3¢gæeS.Rb$Wÿ˜Æ•.l*#C†°<EFBFBD>ŒØÌ<EFBFBD>Þ6‰é€±°]™t‚TBÜÚ’éÒ±³ÒËCb1yô[GëeiEΓÃÏD›½Ò²¯wÖyoð´Äv霟yŸŸwí8"'ãòÄm[ÞÉÒ©K½ƒo¡DY·oZ.j´.ò\Â+ Gá‘Õ9ñN³[IEND®B`‚
]KÅæ[þÞÛµäáitfXb`†•3äÕd‡E?æf ú~ÑrÁ™yóÛx€<EFBFBD>yæ÷Ü+æjô©5϶¶ù>ª[+_¶Èï b´ÿ3õÿÊ[óüì<ݶ´¼ýÍÈ“Y<@Ëk 8 <EFBFBD>¡[%oÏØ/`•éá9¼zDùƒh)SÜÍÀ˜ÓÂ3™¨Û#›µdl-+O<EFBFBD>¾ÙD‹„¦Ñö36cŒì›R§y‘ÆKs—¿bª§ùÒôc \´o¬uKÆì<EFBFBD>×ß¿+<EFBFBD>µËš]L™^°œW>©AZ¶žGÝ>R?2°¿Î¯9å yºeSÊ:JíW<EFBFBD>áÛØÿ? í³<EFBFBD>g´1fžíGåOCû3<EFBFBD>fæ ²éáUÓXZªç>ñ‘ðÜû} cg•<EFBFBD>ÆkÏ®œ(˜¬Á^êÄwöXö"DwyÜ~„ÔN{wö¥FºFdp{–Ïâf…Æ–GkeThýëw±(ÍZï÷ „tmË=ÍAH¦€q&¹ÕºÝÄ•ç{brô8ƒΤ—µx‹pèf<EFBFBD>ãûÖó¿²íÖ=ï™Öó†t3¢gæeS.Rb$Wÿ˜Æ•.l*#C†°<EFBFBD>ŒØÌ<EFBFBD>Þ6‰é€±°]™t‚TBÜÚ’éÒ±³ÒËCb1yô[GëeiEΓÃÏD›½Ò²¯wÖyoð´Äv霟yŸŸwí8"'ãòÄm[ÞÉÒ©K½ƒo¡DY·oZ.j´.ò\Â+ Gá‘Õ9ñN³[IEND®B`‚‰PNG

IHDR`òñ¬ˆ„iCCPICC profile(‘}‘=HÃ@Å_S¥*-vqÈP<EFBFBD>ìbEK‹`¡´Zu0¹ô š4$).Ž‚kÁÁ<EFBFBD>Ūƒ‹³®®‚ øâìà¤è"%þ/)´ˆñà¸ïî=îÞB«ÆT³/¨šed’ 1_X¯ð#„AD“˜©§²‹9xŽ¯{øøzåYÞçþ!¥h2À'Ç™nXÄij›–ÎyŸ8Ì*’B|N<eй.»üƹì°À3ÃF.3O&Ë=,÷0« qDQ5Êò.+œ·8«µëÜ“¿0XÔV²\§9Ž$–<EFBFBD>B"d4PE ¢´j¤˜ÈÐ~ÂÃ?æøÓä’ÉUêP!9~ð?øÝ­YŠM»IÁÐÿbÛ@`h7mûûضÛ'€ÿ¸Òºþz ˜û$½ÙÕ"GÀð6pqÝÕä=àr}Ò%Cr$?M¡TÞÏè›
ÀÈ-0´æöÖÙÇé<EFBFBD>£®–o€ƒC`²LÙëïèííß3<EFBFBD>þ~Õ>rÎ"M‡žbKGD—?Ÿ pHYs.#.#x¥?vtIMEè 0*Ÿ_±¥tEXtCommentCreated with GIMPW<EFBFBD>=IDATxÚí<EFBFBD>ÑŽã E›ˆÿÿåîS%6jwû6×缌F*`cLæñ€†<ŸÏ'Z€»Û_eÝF\­ý«å‰¶—•³Êóg"XØ<'2å£:9êàŒNzS b"@[¥EÑüûlYY:`"ï3ÜïÐñŒñlÛ¶Íå·mÛV3œlŸ<EFBFBD>:<[V¡wÈ¢ëç¬PÔ3—<EFBFBD>ÿF–WëTÕÎêïp–îûÊK€ÿ…³ÕuÓÝ<ßÐqré~(X-l†:¼lO±”éhûÙ~<EFBFBD>
hž¹£ý˜ËÎu~Sß¿<8εÇ{<EFBFBD>ë(úÞ^w+?û<EFBFBD>¡Ìþ̾À@°ìø9îIÎöÇQˆÌ'‘ìFšLûNù<EFBFBD>.SGÇöUúw ¾×Æ­®ŸÓºWì]Ϧɴ_I~Gùl]ôÏìï<EFBFBD>@ï©8Žª˜²ud) ›Zb¶ãÒ›»}©w'–ÈzQWv<EFBFBD>
úwEp2Ýé=Fø@•µXÖ“ž­‡YóoDô¡HâŒÕïjy26<îfÀŠìl]œˆ[†Ù<EFBFBD>¬¸„èʸÃV=@¢Þ=tŒ$í©^BeÚVgæí²†V•w>ÿhyÞøÖÿ À[2AT›€²ígÛîÚÿý¶|Ö†2e‘>•ÿ¶^Å<EFBFBD><EFBFBD>™ç_b+pf;îñ÷ÑÃ,ѲGù³ý<EFBFBD><|¶3÷î·êFªH]»Â¾Íœ
û…3‰”í¾±„ÁïiÿWQѯ³À.EÎ
ëhÀYùUé´¢õÜÁéÝá~J‡üãƒàÊ%Àf]U£ÌQÿàùoÙ÷Ù¢³×v#‚«£<EFBFBD>îvç’¿ÛÚQñ.cõÁë,CF5Ãͦ£r¦Äv8Ò¹ÿgÁ£üŽAXåTäù)ìîÁ¦¼[>R¾ZûgëÈÇ|÷û3u|º×ïÛ:ÔòGÊgŸÕF¤LÛ.û—'„èV^]N‘PãLŸbDêpß®ìØŨ¸™ù˜<EFBFBD>#úüö·ß.¤a+dK²I1”W¼GäŽ&•±oßV¤´Ê΀ΔXî@1 <EFBFBD>¿Rj¬+õ¯Ð]Vþnè¨0kf¯–&%–fs&„©`ƒ+öWvÂe¼ aè¼|Q¥±‹Ô%s
ºj2‘W¿3II£³øü{‡þ‰Ø¼ •ñºÂ(÷yhÎck£¸L>ˆŒýeì6›Ó@ù
6*íüsÊÒu+µBnÇ!®Šöç`@ ÇÓùfÛ
u€Ñ(Žâ®Z^qUuœºcàžÍß%9›Äm¿ÖpRuž»kyeìî¿s àr`ÙŒLîç7\¿j8Ê:’%ÔJ ¥òW ÒL°rû«²j€â<væ,uö,vÖx”÷Ûcüy=¬<EFBFBD>¹íˆ€ˆœXƒlN€Ù>ÁwC€ÀÝ"åA¿gç<<EFBFBD> Œâ‚Z,ýìÜG¢ÕýÿV¦]yÙu=³ó<¾ú8mäzõŒT8N¬°A&ƒûkÍÝSþÚ<EFBFBD>Yw(nWÍÜëƺÉÇ6QA–Õô¿W1‚LÙÎ;á²×;ËŸ­'{3±ræ]Õ í÷J[wPàœ<EFBFBD>€™<>ð\ú«ôÜ®–ã]><EFBFBD>+e <EFBFBD>:Q@özêŽGb+DUŽC#ëyÜçÑß?3gõóøŠþWø†Ý9+óÑvOÙ²ÒxùœÆrbµ¼’ ‘wa,à6ë÷Õ—‘‘r$Iêt+Þèç<EFBFBD>ÒkÖÚ‘IEND®B`‚

File diff suppressed because one or more lines are too long

Binary file not shown.

@ -44,7 +44,7 @@ public:
bool OnUserUpdate(float fElapsedTime) override
{
Clear(VERY_DARK_BLUE);
/*
view.HandlePanAndZoom();
const Tileset&tileset=tilesets[activeTileset];
@ -62,10 +62,10 @@ public:
}
for(auto&[objName,obj]:tileset.objects){
view.DrawLineDecal(obj.bounds.pos,obj.bounds.pos+vf2d{2.f,float(obj.bounds.size.y)},YELLOW);
view.DrawLineDecal(obj.bounds.pos,obj.bounds.pos+vf2d{float(obj.bounds.size.x),2},YELLOW);
view.DrawLineDecal(obj.bounds.pos+obj.bounds.size,obj.bounds.pos+obj.bounds.size+vf2d{-2.f,-float(obj.bounds.size.y)},YELLOW);
view.DrawLineDecal(obj.bounds.pos+obj.bounds.size,obj.bounds.pos+obj.bounds.size+vf2d{-float(obj.bounds.size.x),-2.f},YELLOW);
view.DrawLineDecal(obj.bounds.pos,obj.bounds.pos+vf2d{0.f,float(obj.bounds.size.y)},YELLOW);
view.DrawLineDecal(obj.bounds.pos,obj.bounds.pos+vf2d{float(obj.bounds.size.x),0.f},YELLOW);
view.DrawLineDecal(obj.bounds.pos+obj.bounds.size,obj.bounds.pos+obj.bounds.size+vf2d{0.f,-float(obj.bounds.size.y)},YELLOW);
view.DrawLineDecal(obj.bounds.pos+obj.bounds.size,obj.bounds.pos+obj.bounds.size+vf2d{-float(obj.bounds.size.x),0.f},YELLOW);
vi2d nameTextSize=GetTextSizeProp(objName)*0.25f;
view.GradientFillRectDecal(obj.bounds.pos,nameTextSize+vf2d{2,2},RED,{255,0,0,64},{255,0,0,64},RED);
@ -89,13 +89,22 @@ public:
const TilesetObject&obj=tileset.objects.at(selectedObj);
const bool EditingQuad=editingPoint<4&&editingQuad!=nullptr;
auto GetSnapPoint=[&](){
vf2d worldCoords=view.ScreenToWorld(GetMousePos());
if(GetKey(CTRL).bHeld){
return vf2d{round(worldCoords.x),round(worldCoords.y)};
}
return vf2d{round(worldCoords.x/tileset.tilewidth)*tileset.tilewidth,round(worldCoords.y/tileset.tileheight)*tileset.tileheight};
};
if(EditingQuad){
(*editingQuad)[editingPoint]=view.ScreenToWorld(GetMousePos());
(*editingQuad)[editingPoint]=GetSnapPoint();
}
if(GetMouse(Mouse::LEFT).bPressed){
if(EditingQuad){
(*editingQuad)[editingPoint]=view.ScreenToWorld(GetMousePos());
(*editingQuad)[editingPoint]=GetSnapPoint();
editingPoint++;
}else{
if(obj.collisionTiles.size()==0){
@ -127,13 +136,13 @@ public:
view.DrawPolygonDecal(nullptr,points,uvs,cols);
}
}
*/
//Font test.
DrawStringDecal({0,0},"the quick brown fox jumps over the lazy dog 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f});
/*DrawStringDecal({0,0},"the quick brown fox jumps over the lazy dog 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f});
DrawStringDecal({0,18},"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f});
DrawStringPropDecal({0,36},"the quick brown fox jumps over the lazy dog 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f});
DrawStringPropDecal({0,54},"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f});
*/
return true;
}

@ -6307,6 +6307,7 @@ namespace olc
mapKeys[DOM_PK_END] = Key::END; mapKeys[DOM_PK_PAGE_UP] = Key::PGUP; mapKeys[DOM_PK_PAGE_DOWN] = Key::PGDN;
mapKeys[DOM_PK_BACKSPACE] = Key::BACK; mapKeys[DOM_PK_ESCAPE] = Key::ESCAPE;
mapKeys[DOM_PK_ENTER] = Key::ENTER; mapKeys[DOM_PK_NUMPAD_EQUAL] = Key::EQUALS;
mapKeys[DOM_PK_NUMPAD_ENTER] = Key::ENTER; mapKeys[DOM_PK_PAUSE] = Key::PAUSE;
mapKeys[DOM_PK_SCROLL_LOCK] = Key::SCROLL;
mapKeys[DOM_PK_NUMPAD_0] = Key::NP0; mapKeys[DOM_PK_NUMPAD_1] = Key::NP1; mapKeys[DOM_PK_NUMPAD_2] = Key::NP2;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Loading…
Cancel
Save