Forum

> > CS2D > Scripts > [Solved]Buy menu weapons moving formula?
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Solved]Buy menu weapons moving formula?

5 replies
To the start Previous 1 Next To the start

old [Solved]Buy menu weapons moving formula?

Mora
User Off Offline

Quote
The title says it, as You may notice in the buy menu when You point for example "rifles" You will see all the rifles moving in a circle. I need that formula for my ... mod.(yeah, still dev a shit in my lovely game).

/EDIT: A guy helped me in DM

The code he gave me:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pi2 = 2 * math.pi
path = './gfx/weapons/'

item_list = {
    {name = 'galil_m.bmp'},
    {name = 'ak47_m.bmp'},
    {name = 'sg552_m.bmp'},
    
    {name = 'scout_m.bmp'},
    {name = 'awp_m.bmp'},
    {name = 'g3sg1_m.bmp'},
    {name = 'sg550_m.bmp'},
}

center_x, center_y = 300, 200
radius = 64
rot_speed = 1

angle_diff = pi2 / #item_list -- угол между предметами

-- просчитываем углы для каждого предмета + создаём картинку
for i, item_tab in next, item_list do
    item_tab.angle = i * angle_diff
    item_tab.image = image(path .. item_tab.name .. '<m>', 0, 0, 2)
end

local dt = os.clock()

timer(1, 'cycle', _, 0)
function cycle()
    dt = os.clock() - dt
    
    for i, item_tab in next, item_list do
        local x = center_x + math.cos(item_tab.angle) * radius
        local y = center_y + math.sin(item_tab.angle) * radius
        
        imagepos(item_tab.image, x, y, 0)
        item_tab.angle = (item_tab.angle + rot_speed*dt) % pi2
    end
    
    dt = os.clock()
end
edited 10×, last 18.06.23 01:21:57 pm

old Re: [Solved]Buy menu weapons moving formula?

Mora
User Off Offline

Quote
Guy that helped me might not want to post the code here, that's why he sent me DM. I will ask him if he dont mind and EDIT the whole post and this reply.

/Changed topic and posted his code.
edited 1×, last 18.06.23 01:22:15 pm

old Re: [Solved]Buy menu weapons moving formula?

Mora
User Off Offline

Quote
@user Gaios: even tho Masea is my friend is not him. Nevermind.

Just start new game, press B(enter the buy menu) and aim on any weapon group, for example pistols, You might see that preview section will show You all weapons of the selected section moving by circle, so I needed the formula, or the way these images moving by circle is implemented.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview