To prove I'm not completely rusty when it comes to scripting I decided to write a Ring Menu script.
Yes, much like the ones that have come before it. However! There is a difference.
Since I do not currently understand the math used in the other Ring Menus, I have decided to use my own ideas to produce the same results.
The whole thing is based off of the equation of a circle of course.
If (h,k) is the origin and (x,y) is a point that lies on the circle, then : (x-h)^2 + (y-k)^2 == radius^2 .
I have finished the bulk of it tonight and should be able to do the calculations by the end of next week.
I have no means of testing it, so when I finish the script it would be wonderful if someone would test it for me.
To all scripters who read this topic : I apologize if this is not as optimized as it could be. If it has to do with the math I do then it is something people will have to live with. Half the point of writing this script is to see if I can do it this way.
Spoiler for Ring_Menu {INCOMPLETE} :
class Window_Ring_Command < Window_Command def initialize(x,y,width, commands) super(x, y, width, commands.size * 32 + 32) @item_max = commands.size @commands = commands @column_max = @item_max self.contents = Bitmap.new(width - 32, 32) refresh self.index = 0 end def refresh self.contents.clear draw_item(@index, normal_color) end def draw_item(index, color) self.contents.font.color = color rect = Rect.new(4,32,self.contents.width - 8,32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) self.contents.draw_text(rect, @commands[index],1) end def update_cursor_rect(cursor = false) if cursor cursor_width = self.width - 32 self.cursor_rect.set(0,0,cursor_width,32) else self.cursor_rect.empty end end def update if @old_index != nil and @old_index != @index refresh end super @old_index = @index.clone end def set_opacity(opacity) self.opacity = opacity self.back_opacity = opacity end end class Ring_Menu def initialize(x,y,radius,commands = [],icons = [],origin = true) # Retrive important values and initalize icon array @x = x*1.0 @y = y*1.0 @radius = radius*1.0 @diameter = @radius * 2 @commands = commands @icon_names = icons @icon_sprites = [] # If origin is true, then (x,y) = (h,k) # If origin is false, then (x,y) are the x and y of the whole ring menu @origin = origin # Retrive alternate opacity if provided if yield != nil @opacity = yield else @opacity = 0 end # Find all of the points on the circle if @origin # Find all of the points on the circle a1 = @x - radius b1 = @y - radius a2 = @x + radius b2 = @y + radius else a1 = @x b1 = @y a2 = @x + @diameter b2 = @y + @diameter end a_range = a2 - a1 b_range = b2 - b1 temp_points = [] for i in 0..a_range for j in 0..b_range temp_points.push[a1+i,b1+j] end end @points_on_circle = [] if @origin temp_points.each do(|n| if (n[0]-@x)**2+(n[1]-@y)**2 == @radius**2 @points_on_circle.push(n) end) else temp_points.each do(|n| if (n[0]-(@x+@radius))**2+(n[1]-(@y+@radius))**2 == @radius**2 @points_on_circle.push(n) end) end # Create command window to display option text @command_window = Window_Ring_Command.new(a1,b2+1,@diameter,@commands) @command_window.set_opacity(@opacity) # Create icons for ring menu for i in 0..@icon_names.size @icon_sprites.push(Sprite.new) @icon_sprites[i].bitmap = RPG::Cache.icon(@icon_names[i]) # <^> Instructions to retrive appropriate initial x and y coordinates <^> @icon_sprites[i].x = icon_x @icon_sprites[i].y = icon_y end end def move_icons # <^>Instructions for moving sprites <^> end def update # Move the icons if the index has changed if @old_index != nil and @old_index != @index move_icons end # Update the command window and store the current index @command_window.update @old_index = @command_window.index.clone end end
P.S. From now on, if I post a script that is tested and works, I will place this image at the beginning of the thread -
This is something I drew a long time ago about 2 in the morning, and I thought it would be cute.
EDIT: I hope nobody caught that embarassing error that was in the portion of the code completed. I can't call myself a scripter if I let something like that go unchecked.