Discord
Login
Community
DARK THEME

How to make this work??? (timer, collectable)

I have a big problem. I am still on my project and I need someone to help me because I want to make a level were you have to collect so called "soulstones" to have enought time to let the flame(player) burn. I tried to programm the deadscreen 1 when the timer is at zero and it worked but as soon as I stardet to try making the stones my deadscreen started scrolling permantly up and coming again from out of the floor. Is there somewhone who can help me? I made a copie of the game puplic. It is called "The Dark! (copy)".

https://microstudio.io/i/Jays_J/thedark2/

please I NEED HELP!

BTW Now nothing works without the playermovement

Okay, there are several missing functions, and some of them don't have their "()" when used

thx. could u maybe helb me fixing this problem when i add you to the copy of the game?

Oh, sorry, I hadn't seen the reply; and yes, if you want

I added you. hopefully you can show me how to make it work

Let's see, in the soulstonestimesadd file, there are some functions you're using, called distance and randRange, which don't exist because they need to be defined in a file

I just created the functions in the file called functions:

distance = function(a,b)
  return sqrt(a*a+b*b)
end

randRange = function(a,b)
  return a+random.next()*(b-a)
end

Remember, if text is white, it's because you need to create or define it somewhere in your project; if it's blue, then it already exists without needing to be defined in any file

Also, double-check the names, because in the soulstonestimesadd file, the function randomizeCoinPos (this does not exist) was used instead of randomizeStonePos (this one exists)

Now that the errors are gone, all that's left is to draw the sprite in the solustones positions. I don't know if you want to do it yourself or if you want me to do it; it's technically the same as drawing the player

thank you. :) Can you show me how I have to do it so that the programm of random spawning works with the drawing part?

Ah, it's very simple. When you draw the player, you use:

screen.drawSprite("player", player.x, player.y 15,15)

You must do the same for the stone; it's just a stone, so every time the player approaches, the stone will change its coordinates, as indicated in this function:

randomizeStonePos = function()
  // "randRange" needed to be defined
  soulstones.x = randRange(-150, 150)
  soulstones.y = randRange(-80, 80)
end

Then, after drawing the player, you must draw the stone using its coordinates (Although the order doesn't matter, it can be before or after) :

//draw the player
screen.drawSprite("player", player.x, player.y 15,15)
//draw the soulstone
screen.drawSprite("soulstones",soulstones.x,soulstones.y,15,15)

and sorry, I made a mistake somewhere. I entered the distance function incorrectly; it should be like this:

distance = function(x1,y1,x2,y2)
  local dx = x1-x2
  local dy = y1-y2
  return sqrt(dx*dx+dy*dy)
end

Even so, I've already corrected the errors, I think it should be working correctly now, and another problem I saw at the beginning was that you had to enter InitCoin with the parentheses, but I've already fixed that:

init = function()
  //object virables
  player = object end
  enemy = object end
  soulstones = object end
  initCoin() // <- The parentheses were missing
  // ...

OMG THANK YOU SO MUCH. IT FINALLY WORKS. You're a kind person. Thank you. Have a good day!

:)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community