Skip to content

Commit

Permalink
Make the star item droppable (#53)
Browse files Browse the repository at this point in the history
* Make the star item droppable

* Make the star item droppable

* Fix issues

---------

Co-authored-by: BuildTools <[email protected]>
  • Loading branch information
Anthcny144 and BuildTools authored Aug 22, 2024
1 parent 9ee1dfc commit 120f78e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 23 deletions.
Binary file added images/sprites/sprite_etoile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion php/pages/challengeZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ function feedCustomDecorData(res) {
<div class="zone-editor-decor">
<span><?php echo $language ? 'Item:':'Objet :'; ?></span>
<?php
$itemTypes = array('banane', 'carapace', 'carapace-rouge', 'fauxobjet', 'champi', 'poison');
$itemTypes = array('banane', 'carapace', 'carapace-rouge', 'fauxobjet', 'champi', 'poison', 'etoile');
foreach ($itemTypes as $key) {
$src = isset($editorContext['customIcons'][$key]) ? $editorContext['customIcons'][$key] : $key;
?>
Expand Down
80 changes: 58 additions & 22 deletions scripts/mk.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,11 @@ var oPlanWidth, oPlanSize, oPlanRealSize, oCharWidth, oObjWidth, oCoinWidth, oEx
var oPlanWidth2, oPlanSize2, oCharWidth2, oObjWidth2, oCoinWidth2, oExpWidth2, oExpBWidth2;
var oCharRatio, oPlanRatio;
var oPlanCharacters = new Array(), oPlanObjects = new Array(), oPlanCoins = new Array(), oPlanPoisons = new Array(), oPlanDecor = {}, oPlanAssets = {}, oPlanSea,
oPlanFauxObjets = new Array(), oPlanBananes = new Array(), oPlanBobOmbs = new Array(), oPlanChampis = new Array(),
oPlanFauxObjets = new Array(), oPlanBananes = new Array(), oPlanBobOmbs = new Array(), oPlanChampis = new Array(), oPlanEtoilesDrop = new Array(),
oPlanCarapaces = new Array(), oPlanCarapacesRouges = new Array(), oPlanCarapacesBleues = new Array(), oPlanCarapacesNoires = new Array(),
oPlanEtoiles = new Array(), oPlanBillballs = new Array(), oPlanTeams = new Array();
var oPlanCharacters2 = new Array(), oPlanObjects2 = new Array(), oPlanCoins2 = new Array(), oPlanDecor2 = {}, oPlanAssets2 = {}, oPlanSea2,
oPlanFauxObjets2 = new Array(), oPlanBananes2 = new Array(), oPlanBobOmbs2 = new Array(), oPlanPoisons2 = new Array(), oPlanChampis2 = new Array(),
oPlanFauxObjets2 = new Array(), oPlanBananes2 = new Array(), oPlanBobOmbs2 = new Array(), oPlanPoisons2 = new Array(), oPlanChampis2 = new Array(), oPlanEtoilesDrop2 = new Array(),
oPlanCarapaces2 = new Array(), oPlanCarapacesRouges2 = new Array(), oPlanCarapacesBleues2 = new Array(), oPlanCarapacesNoires2 = new Array(),
oPlanEtoiles2 = new Array(), oPlanBillballs2 = new Array(), oPlanTeams2 = new Array();
var customDecorFetchHandlers = [{plan:oPlanDecor,list:{}},{plan:oPlanDecor2,list:{}}];
Expand Down Expand Up @@ -1164,6 +1164,14 @@ function setPlanPos(frameState, lMap) {
setObject(oPlanChampis2[i],champi.x,champi.y, oObjWidth2,oPlanSize2, -1,100);
oPlanChampis[i].style.zIndex = oPlanChampis2[i].style.zIndex = 2;
}
syncObjects(oPlanEtoilesDrop,frameItems["etoile"],"etoile", oObjWidth,oPlanCtn);
syncObjects(oPlanEtoilesDrop2,frameItems["etoile"],"etoile", oObjWidth2,oPlanCtn2);
for (var i=0;i<frameItems["etoile"].length;i++) {
var etoile = frameItems["etoile"][i];
setObject(oPlanEtoilesDrop[i],etoile.x,etoile.y, oObjWidth,oPlanSize, -1,100);
setObject(oPlanEtoilesDrop2[i],etoile.x,etoile.y, oObjWidth2,oPlanSize2, -1,100);
oPlanEtoilesDrop[i].style.zIndex = oPlanEtoilesDrop2[i].style.zIndex = 2;
}

function getExplosionSrc(src,team,defaultTeam) {
if (team != -1)
Expand Down Expand Up @@ -1495,6 +1503,7 @@ function resetPlan(lMap) {
oPlanBananes.length = 0;
oPlanBobOmbs.length = 0;
oPlanChampis.length = 0;
oPlanEtoilesDrop.length = 0;

oPlanCarapaces.length = 0;
oPlanCarapacesRouges.length = 0;
Expand All @@ -1515,6 +1524,7 @@ function resetPlan(lMap) {
oPlanBobOmbs2.length = 0;
oPlanPoisons2.length = 0;
oPlanChampis2.length = 0;
oPlanEtoilesDrop2.length = 0;

oPlanCarapaces2.length = 0;
oPlanCarapacesRouges2.length = 0;
Expand Down Expand Up @@ -2271,6 +2281,7 @@ function addNewItem(kart,item) {
var hallowSize;
switch (collection) {
case "champi":
case "etoile":
break;
case "banane":
hallowSize = 50;
Expand Down Expand Up @@ -2333,6 +2344,29 @@ function addNewItem(kart,item) {
}
}

function setStarState(oKart, duration) {
for (var i=0;i<strPlayer.length;i++)
oKart.sprite[i].img.src = getStarSrc(oKart.personnage);
if (!oKart.cpu && !oKart.etoile) {
if (!isOnline) {
oKart.sprite[0].img.onload = function() {
bCounting = false;
this.onload = undefined;
reprendre(false);
}
interruptGame();
bCounting = true;
}
if (shouldPlaySound(oKart) && !oPlayers[1])
postStartMusic("musics/events/starman.mp3");
}
if (oKart.speedinc > 0)
oKart.speedinc *= 5;
delete oKart.shift;
oKart.protect = true;
oKart.etoile = duration;
}

var CHAMPI_TYPE_ITEM = 1, CHAMPI_TYPE_BOOST = 2;
function arme(ID, backwards, forwards) {
var oKart = aKarts[ID];
Expand Down Expand Up @@ -2370,25 +2404,7 @@ function arme(ID, backwards, forwards) {

case "etoile" :
tpsUse = 80;
for (var i=0;i<strPlayer.length;i++)
oKart.sprite[i].img.src = getStarSrc(oKart.personnage);
if (!oKart.cpu && !oKart.etoile) {
if (!isOnline) {
oKart.sprite[0].img.onload = function() {
bCounting = false;
this.onload = undefined;
reprendre(false);
}
interruptGame();
bCounting = true;
}
if (shouldPlaySound(oKart) && !oPlayers[1])
postStartMusic("musics/events/starman.mp3");
}
if (oKart.speedinc > 0)
oKart.speedinc *= 5;
delete oKart.shift;
oKart.protect = true;
setStarState(oKart, tpsUse);
break;

case "billball" :
Expand Down Expand Up @@ -6986,6 +7002,11 @@ var itemBehaviors = {
sync: [floatType("x"),floatType("y"),floatType("z")],
fadedelay: 100
},
"etoile": {
size: 0.54,
sync: [floatType("x"),floatType("y"),floatType("z")],
fadedelay: 100
},
"eclair": {
size: 1,
sync: [intType("owner")],
Expand Down Expand Up @@ -8182,7 +8203,7 @@ var itemBehaviors = {
}
}
}
var itemTypes = ["banane","fauxobjet","carapace","bobomb","poison","carapace-rouge","carapace-bleue","carapace-noire","eclair","bloops","champi"];
var itemTypes = ["banane","fauxobjet","carapace","bobomb","poison","carapace-rouge","carapace-bleue","carapace-noire","eclair","bloops","champi","etoile"];
var items = {};
for (var i=0;i<itemTypes.length;i++)
items[itemTypes[i]] = [];
Expand Down Expand Up @@ -11121,6 +11142,7 @@ function dropCurrentItem(oKart) {
var itemType;
switch (sArme) {
case "champi":
case "etoile":
case "banane":
case "carapace":
case "poison":
Expand Down Expand Up @@ -14556,6 +14578,17 @@ function touche_champi(iX, iY) {
return false;
}

function touche_etoile(iX, iY) {
for (var i=0;i<items["etoile"].length;i++) {
var oBox = items["etoile"][i];
if (iX > oBox.x - 4 && iX < oBox.x + 4 && iY > oBox.y - 4 && iY < oBox.y + 4) {
detruit(oBox);
return true;
}
}
return false;
}

function touche_fauxobjet(iX, iY, iP) {
if (!iP) iP = [];
for (var i=0;i<items["fauxobjet"].length;i++) {
Expand Down Expand Up @@ -16045,6 +16078,9 @@ function move(getId, triggered) {
oKart.speed = oKart.maxspeed*cappedRelSpeed(oKart);
playIfShould(oKart,"musics/events/boost.mp3");
}
else if ((touche_etoile(fNewPosX, fNewPosY) || (fSelectedClass > 1.5 && touche_etoile(fMidPosX, fMidPosY))) && !oKart.tourne && !oKart.billball) {
setStarState(oKart, 80);
}
else if (!oKart.tourne && (oKart.z < 1.2)) {
var hittable = !oKart.protect && !oKart.frminv;
var asset = touche_asset(aPosX,aPosY,fNewPosX,fNewPosY);
Expand Down

0 comments on commit 120f78e

Please sign in to comment.