Discord
Login
Community
DARK THEME

Tip For my incremental game

the current issue I'm having is only 1 button will show up when I have the correct code for 2 buttons

Have you used a list? or an identifier for your button

yes but idk how to add that button to my list I already have 1

Try using (name of your list) + push(new...(name of the button...). For example: hello = [] hello.push(hi = object = x = 0 y = 0 end)

dude it worked perfectly thx

ok both buttons show up but now only 1 works and they are both in a list

its telling me that "checkRectMouseHover = function() is not a function even tho I declared it a function in a different file

  BaseBoost = 0
  MultiBoost = 1
  ExpondentalBoost = 1
  Point_Gain = (((1 + BaseBoost) * MultiBoost) ^ ExpondentalBoost) 
//Upgrade button 
  buttons = []
  buttons.push(
    button = object
      x = 175
      y = 75
      width = 45
      height = 45
      text = "Points Upgrades"
      action = function() print("success") end
      scale = 1
      alpha = 4
    end
  )
  
for button in buttons
    //check hover
    button.scale = 1
    if checkRectMouseHover(button.x, button.y, button.width, button.height) then
      button.alpha = 1
      if mouse.press then
        button.action()
      end
      if mouse.pressed then
        button.scale = 1.1
      end
    else
      button.alpha = 0.7
      end
    end
  
  
  draw = function()
   // set up the game
  screen.clear()
  screen.fillRect(0, 0, 400, 400, "rgb(142,217,255")
  screen.setFont("RetroGaming")
  // draw the Points
  screen.drawText("Points: " + Points, -125,85,15 "rgb(0,0,0)")
  for button in buttons
    screen.setDrawScale(button.scale, button.scale)
    screen.setAlpha(button.alpha)
    screen.fillRoundRect(button.x-100, button.y-10,
      button.width+50, button.height+50,"rgb(255,255,255)")
    screen.drawSprite("point_upgrades", 175, 75, 45, 45)
    screen.drawText(button.text, button.x-100, button.y-10)
    screen.setDrawScale(1, 1)
    screen.setAlpha(1)
  end```

Bring me an invitation so I can help you

https://microstudio.io/Arch_1/incremental/TestingGround/

ok I'll coming

I went afk I thought you were not going to reply until tomarrow

and they are for each button

Okay, I see the problem. First, you have init and you're not using classes. If you don't mind, I can fix all that while keeping your ideology.

ok

Give me your main values... I'm going to calculate a remuneration, let's go. You can assist me if you want.

main values like the variables that are declared?

ok we got Points, Points_Gain, SavedData, hover, BaseBoost, MultiBoost, ExpondentalBoost, frameCount, draw function, buttons list, init function, save game function, update function, and chechRectMouseHover function

Okay, I've started from scratch. Come take a look and add what's missing. Sorry, I didn't understand anything.

uhhhhh? I went afk and I came back and the point system is gone?

I'm sorry if I bothered you too much

Sorry, everything is perfect now, try it and you'll see.

Post a reply

Progress

Status

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