How to buy weapons or items using points and doing waves?

Hi Again Um I have a question. Ok what I want to have is like a shop in the game, and in the shop you buy items only using points accumulated while you were playing and using them. Also having enemies spawn like in every wave but the amount of enemies increase each time. Ok what I’m trying to get is this.

How do I do a shop do to buy items with the accumulated points and use that item?

How would I make a waves like making enemies spawn when you have destroyed them all and making them stronger every time?
or spawning more in each wave?(which I don’t think spawning more enemies on each wave is good because can slow down game)

and that it

Help is appreciated :slight_smile:

[import]uid: 17058 topic_id: 19881 reply_id: 319881[/import]

You’d use an integer (eg, level=1) to keep track of which wave the player was on and could use that to modify the the health/damage/etc of enemies.

For the shop you’d have gold = 1000 (or whatever) and then buttons to buy items where you’d check gold > itemPrice, then subtract that amount of gold and give the user the item if so.

Peach [import]uid: 52491 topic_id: 19881 reply_id: 77265[/import]

spawning enemies in waves with different types of enemies after some criteria and make them harder, faster and so on
i did this for a game and i must say its not an easy logic, as a noob programmer my skills was put to the test) [import]uid: 16142 topic_id: 19881 reply_id: 77274[/import]

@darkconsole thanks for telling me that is complicted to do. Then what about just only spawning enemies in each wave but more everytime you think that is hard also.

@peach how would I give the user the item [import]uid: 17058 topic_id: 19881 reply_id: 77277[/import]

for me problem was to keep track of spawned enemies on wave so new wave was activated only when i destroy all of them
everything else is not too hard [import]uid: 16142 topic_id: 19881 reply_id: 77284[/import]

@darkconsole yeah that what I mean for only spawning enemies is when I destroy them all how would I do that. [import]uid: 17058 topic_id: 19881 reply_id: 77304[/import]

you must to use a variable to determine how much enemies are spawning this wave and then at each enemy kill check if enemy kill count = enemy spawn number and then call wave changing function where all stats will be changed as you please, new timers involved and checks for new types of enemies and so on

i cant explain it, its too much of a code(actually for me its 2000 lines for all the logic with 5 different types of enemies) )

but i can recommend to write logic on paper before writing it in code, its really helpful approach for complex functions [import]uid: 16142 topic_id: 19881 reply_id: 77308[/import]

I don’t do shoot em ups myself, but here is a way I might approach that…
(there are dozens of other ways)

First, you need a table holding information about the enemies.
Because every enemy needs some attributes such as health, strength, and so on.
An enemy is dead when the health is 0
The wave is dead when all enemies have zero health.
You have

To create 10 enemies, you might do something like this:

\_G.numberOfEnemies = 10  
\_G.wave = 1  
enemies = {}  
  
local function spawnEnemies(howMany,strengthVal, healthVal)  
  
for x = 1 , howMany, 1 do  
enemies[x] = {strength=strengthVal, health = healthVal,type = "tank"}  
--and create sprites and set then going..  
end  
end  
  
spawnEnemies(\_G.numberOfEnemies, 10, 20)  
  

When an enemy takes damage,

enemies[8].health = enemies[8].health -1  

an enemy is dead when the health is 0
To know if the wave is dead:

local function isEveryoneDead()  
local ret = true  
for x = 1, \_G.numberOfEnemies, 1 do  
  
if enemies[x].health \> 0 then ret = false  
  
end  
return ret  
end  

To increase the number next time:

--bump up the wave number  
\_G.wave = \_G.wave +1  
--use this to change the attributes of the new wave  
\_G.numberOfEnemies = \_G.numberOfEnemies \* \_G.wave  
  
spawnEnemies(\_G.numberOfEnemies, 10 + \_G.wave, 20 + \_G.wave)  

As I say, probably millions of other/better ways, but maybe this will help?
[import]uid: 108660 topic_id: 19881 reply_id: 77310[/import]

Jeff, what did you do there with spawning enemies?
i tried this and its not giving enemies health parameters
[lua]enemies = {}

for i=1,10 do
enemies[i] = {health = 10}
enemies[i] = display.newRect(0,0,20,20)
enemies[i].x = math.random(10,300)
end

for i=1,10 do
print(enemies[i].health)
end[/lua]

but its working like this:
[lua]enemies = {}

for i=1,10 do

enemies[i] = display.newRect(0,0,20,20)
enemies[i].params = {health = 10}
enemies[i].x = math.random(10,300)
end

for i=1,10 do
print(enemies[i].params.health)
end[/lua] [import]uid: 16142 topic_id: 19881 reply_id: 77314[/import]

@jeff472 thanks for the example I will reply back again if I having any problems [import]uid: 17058 topic_id: 19881 reply_id: 77325[/import]