Thread: Wheel Of Fortune

Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20
  1. #11  
    Registered Member
    Join Date
    May 2014
    Posts
    162
    Thanks given
    12
    Thanks received
    17
    Rep Power
    54
    Quote Originally Posted by I Got This View Post
    Just waiting when noobies will start complaining there are errors xD

    Is that so you can see the replies they get to fix the errors you've got?
    Reply With Quote  
     

  2. #12  
    Extreme Donator

    Bennie's Avatar
    Join Date
    Jun 2013
    Posts
    2,095
    Thanks given
    868
    Thanks received
    796
    Rep Power
    5000
    Eyo this is cool
    Reply With Quote  
     

  3. #13  
    Registered Member
    Join Date
    May 2021
    Posts
    23
    Thanks given
    4
    Thanks received
    2
    Rep Power
    11
    Quote Originally Posted by TNS Alphonse View Post
    Is that so you can see the replies they get to fix the errors you've got?
    I'm not using this at all and there are no errors only missing methods wich are alredy inside most clients just differently named simple stuff.
    Reply With Quote  
     

  4. #14  
    Registered Member
    Join Date
    Apr 2018
    Posts
    27
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Gonna just say Thanks! I have some ideas for this and appreciate the release.

    EDIT: Figured it out.
    Reply With Quote  
     

  5. #15  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    There's something wrong about it in my eyes, when rotating the items, why aren't they aligned with their block? they shouldn't rotate as if they we're facing straight but rather
    align along to their respective block? hope it makes sense lol
    Reply With Quote  
     

  6. Thankful user:


  7. #16  
    nice


    Join Date
    Jul 2014
    Posts
    740
    Thanks given
    382
    Thanks received
    562
    Rep Power
    4239
    Quote Originally Posted by Tyrant View Post
    There's something wrong about it in my eyes, when rotating the items, why aren't they aligned with their block? they shouldn't rotate as if they we're facing straight but rather
    align along to their respective block? hope it makes sense lol
    It somewhat makes sense but not really at the same time, it looks fine to me.
    Got a gif of what it should look like in ur eyes vs how it looks like in case or some kind of other example?
    Attached image
    Reply With Quote  
     

  8. #17  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Quote Originally Posted by Suic View Post
    It somewhat makes sense but not really at the same time, it looks fine to me.
    Got a gif of what it should look like in ur eyes vs how it looks like in case or some kind of other example?
    Sure.

    Notice how each element faces the middle of the circle, giving it a natural feeling of actually being rotated.

    https://www.reddit.com/r/gifs/commen...el_of_fortune/
    Reply With Quote  
     

  9. Thankful user:


  10. #18  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    27
    Posts
    543
    Thanks given
    224
    Thanks received
    100
    Rep Power
    113
    Quote Originally Posted by Tyrant View Post
    Sure.

    Notice how each element faces the middle of the circle, giving it a natural feeling of actually being rotated.

    https://www.reddit.com/r/gifs/commen...el_of_fortune/
    Something else to consider is the wheel pointer can alter the visuals a bit too
    If for example the pointer was on the sides rather than the top, it would make sense to have the items upright, simply because if they were facing the center, and your pointer was on the left or right, you'd have horizontal items with the pointer coming in horizontally through the the top of the item which is now horizontal, rather than a vertical item with the pointer coming in horizontally

    Also in your image, the tops face the center, rather than the bottom, so in the case of this wheel, just for examples sake, going back to what I was saying about the visual perception, that would look quite strange. Haha. Would work if the bottoms faced the center tho.

    Quote Originally Posted by Suic View Post
    It somewhat makes sense but not really at the same time, it looks fine to me.
    Got a gif of what it should look like in ur eyes vs how it looks like in case or some kind of other example?
    think he means in your current wheel, the items are always "standing" like inventory sprites
    the wheel rotates from top right to bottom right, but the item is still facing up and down rather than like, the hilt of a sword being the bottom, and having that sword hilt facing the middle point of the wheel, rather than the bottom of your screen.

    Anywho, with all that rambling outttt the way, pretty cool lil project and while I wont be usin' it, thanks! and rep+ for not bein a heckin' greedo, like; people still sell map editors, models(of which usually rip assets from other models), and maps themselves for outrageous prices, crap like that? Come on. I feel like the community as a whole really would be different if people hadn't spent the last decade and a half hoarding information, tools, and so on, and doing so for a profit.
    but also, I'm pretty stoned and I ramble when stoned, and I haven't been on here in ages and it's 4 am, soooooooooooooooooooooooooooo, whatever...

    Edit: gotta be real, if anything looks off, though, not to take away from it at all, it's still pretty cooooool... But it's that NPC, he's just... Stiff as a board lmao if even one of his legs were slightly bent, that'd be a drastic improvement, until then, he is boardman manboard.
    Last edited by Lumiere; 11-11-2021 at 09:45 AM.

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  11. #19  
    Banned
    Join Date
    Sep 2021
    Age
    31
    Posts
    19
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Thanks for sharing such a quality work will use it for sure
    Reply With Quote  
     

  12. #20  
    Registered Member jdakiller2's Avatar
    Join Date
    Dec 2013
    Posts
    433
    Thanks given
    13
    Thanks received
    7
    Rep Power
    19
    Quote Originally Posted by Suic View Post
    This is something i wrote a while ago, sold it to 3 ppl and apparently one of them started selling it to other ppl for $100(and some1 actually bought it lol) so i might as well just release it

    Attached image
    You can also give each segment it's own color(actually did that myself but ended up removing it later)
    Credit to Herb for the sprites

    Client code:

    Code:
    import java.util.concurrent.ThreadLocalRandom;
    
    /**
     * @Author Suic
     */
    
    public class WheelOfFortune {
    
        private final int width;
        private final int height;
        private final int strokeWidth;
        private final int color; //unused for now
        private final int alpha;
        private final int closure;
        private final boolean fill;
        private final int segments;
        private final Sprite icon;
    
        private final double arcLength;
    
        private double drag = 0.97;
        private double angleVel = 0;
        private double angle = 0;
        private int index = -1;
        private int currentIndex = -1;
    
        private final double INITIAL_DRAG = 0.993;
        private final double LATER_DRAG = 0.988;
        private final double DRAG_CHANGE_CUTOFF = 3.5;
        private final double END_SPIN_CUTOFF = 0.4;
    
        private int[] items = {6199, 6199, 6199, 6199, 6199, 6199, 6199, 6199, 6199, 6199}; // test
    
        private boolean active;
    
    
        public WheelOfFortune(int width, int height, int strokeWidth, int color, int alpha, int closure, boolean fill, int segments, Sprite icon) {
            this.width = width;
            this.height = height;
            this.strokeWidth = strokeWidth;
            this.color = color;
            this.alpha = alpha;
            this.closure = closure;
            this.fill = fill;
            this.segments = segments;
            this.icon = icon;
            arcLength = 360D / segments;
        }
    
    
        public void render(int x, int y) {
            int idx = 0;
            update();
            for (double theta = 0; theta < 360; theta += arcLength) {
                Raster.drawArc(x, y, width, height, strokeWidth, -(angle + theta), arcLength, 0x3f372c, alpha, closure, fill);
                idx++;
            }
    
            for (int i = 0; i < items.length; i++) {
                Sprite itemSprite = ItemDef.getSprite(items[i], 1, 0);
                if (itemSprite == null) {
                    break;
                }
                double theta = i * arcLength;
                double newPhi = ((angle + theta) + arcLength / 2D);
                double newRadius = width / 3D;
    
                double wheelCenterX = x + width / 2D;
                double wheelCenterY = y + height / 2D;
    
                double arcCenterX = (Math.cos(Math.toRadians(newPhi)) * newRadius + wheelCenterX);
                double arcCenterY = (Math.sin(Math.toRadians(newPhi)) * newRadius + wheelCenterY);
                itemSprite.drawSprite((int) (arcCenterX + 2) - itemSprite.myWidth / 2, (int) (arcCenterY + 2) - itemSprite.myHeight / 2);
            }
    
            icon.drawAdvancedSprite(x + (width / 2) - (icon.myWidth / 2), y - (height / 12), 255);
        }
    
        private void update() {
    
            if (!active) {
                return;
            }
    
            if (angleVel < END_SPIN_CUTOFF) {
                angleVel = 0;
                notifyServer();
                active = false;
                return;
            }
    
            if (angleVel < DRAG_CHANGE_CUTOFF) {
                drag = LATER_DRAG;
            }
    
            angle += angleVel;
            angleVel *= drag;
    
            currentIndex = (int) (Math.floorMod((int) (-angle + (segments * 0.75D) * arcLength), 360) / arcLength);
        }
    
        public void init() {
            this.drag = INITIAL_DRAG;
            this.angle = 0;
            double spinDurationAfterCutoff = Math.log(END_SPIN_CUTOFF / DRAG_CHANGE_CUTOFF) / Math.log(LATER_DRAG);
            double angleAfterDragChange = DRAG_CHANGE_CUTOFF * (1 - Math.pow(LATER_DRAG, spinDurationAfterCutoff)) / (1 - LATER_DRAG);
            double endAngle = ThreadLocalRandom.current().nextInt(3, 7) * 360 - angleAfterDragChange;
            endAngle -= 90 + arcLength / 2; // center index 0 at the marker
            endAngle -= index * arcLength;  // select the index by shifting it so many segments over
            double offset = ThreadLocalRandom.current()
                    .nextDouble(-arcLength / 2 + 5, arcLength / 2 - 5);
            endAngle -= offset;
            double tToCutoff = Math.log(DRAG_CHANGE_CUTOFF / (DRAG_CHANGE_CUTOFF + endAngle * (1 - drag))) / Math
                    .log(drag);
            this.angleVel = DRAG_CHANGE_CUTOFF / Math.pow(drag, tToCutoff);
            active = true;
        }
    
        public void setItems(int[] items) {
            this.items = items;
        }
    
        public void setIndex(int index) {
            this.index = index;
        }
    
        private void notifyServer() {
            Client.stream.createPacket(225);
            Client.stream.writeByte(index);
        }
    }
    Code:
    private static void wheelOfFortune(TextRaster[] font) {
            final int STARTING_POINT = 21350;
            RSInterface main = addInterface(STARTING_POINT);
    
            addSpriteLoader(STARTING_POINT + 1, 1184);
            addWheel(STARTING_POINT + 2, 210, 210, 2, 0x3f372c, 255, 2, true, 10, 1185);
            main.totalChildren(13);
            main.child(0, STARTING_POINT + 1, 50, 10);
            main.child(1, STARTING_POINT + 2, 80, 65);
            addHoverableSprite(STARTING_POINT + 3, 1187, 1188, true, "Spin Wheel");
            main.child(2, STARTING_POINT + 3, 146, 283);
            addTextComponent(STARTING_POINT + 4, "Spin Wheel!", fonts, 0, ColorConstants.RS_ORANGE, false, true, 0, 0);
            main.child(3, STARTING_POINT + 4, 163, 290);
    
            addNPC(STARTING_POINT + 5, 2998);
            main.child(4, STARTING_POINT + 5, 335, 186);
    
            addSpriteLoader(STARTING_POINT + 6, 1186);
            main.child(5, STARTING_POINT + 6, 301, 168);
            addSpriteLoader(STARTING_POINT + 7, 1190);
            main.child(6, STARTING_POINT + 7, 282, 62);
            addTextComponent(STARTING_POINT + 8, "Spin the wheel", fonts, 0, ColorConstants.RS_ORANGE, false, true, 0, 0);
            main.child(7, STARTING_POINT + 8, 291, 72);
            addTextComponent(STARTING_POINT + 9, "for a reward!", fonts, 0, ColorConstants.RS_ORANGE, false, true, 0, 0);
            main.child(8, STARTING_POINT + 9, 296, 84);
            addCloseButton(STARTING_POINT + 10);
            main.child(9, STARTING_POINT + 10, 441, 19);
    
            addTextComponent(STARTING_POINT + 11, "Wheel of fortune", fonts, 2, ColorConstants.RS_ORANGE, true, true, 0, 0);
            main.child(10, STARTING_POINT + 11, 268, 19);
            addTransparentLayer(STARTING_POINT + 12, 0, 120);
            main.child(11, STARTING_POINT + 12, 50, 10);
            main.child(12, STARTING_POINT + 20, 173, 48);
    
            RSInterface rewardInterface = addInterface(STARTING_POINT + 20);
            rewardInterface.setVisible(false);
            rewardInterface.totalChildren(7);
            addSpriteLoader(STARTING_POINT + 21, 1189);
            rewardInterface.child(0, STARTING_POINT + 21, 0, 0);
            addCloseButton(STARTING_POINT + 22);
            rewardInterface.child(1, STARTING_POINT + 22, 164, 9);
            addTextComponent(STARTING_POINT + 23, "Reward", fonts, 2, ColorConstants.RS_ORANGE, true, true, 0, 0);
            rewardInterface.child(2, STARTING_POINT + 23, 94, 10);
            addTextComponent(STARTING_POINT + 24, "You've won:", fonts, 2, ColorConstants.RS_ORANGE, false, true, 0, 0);
            rewardInterface.child(3, STARTING_POINT + 24, 57, 43);
            addHoverableSprite(STARTING_POINT + 25, 1187, 1188, true, "Spin Again!");
            rewardInterface.child(4, STARTING_POINT + 25, 51, 198);
            addTextComponent(STARTING_POINT + 26, "Spin Again!", fonts, 0, ColorConstants.RS_ORANGE, false, true, 0, 0);
            rewardInterface.child(5, STARTING_POINT + 26, 69, 205);
            
            addModel(STARTING_POINT + 27, 75, 50, 4447, 800, 3500);
            rewardInterface.child(6, STARTING_POINT + 27, 63, 105);
    
    
        }
    Code:
        public static void addWheel(int id, int width, int height, int strokeWidth, int color,
                int alpha, int closure, boolean fill, int segments, int spriteId) {
            RSInterface widget = addInterface(id);
            widget.wheel = new WheelOfFortune(width, height, strokeWidth, color, alpha, closure, fill, segments, Client.cacheSprite[spriteId]);
            widget.type = 150;
        }
    
        public WheelOfFortune wheel;

    Server code:

    Code:
    public class WheelOfFortune {
    
        private final int INTERFACE_ID = 21350;
        private final int WHEEL_INTERFACE_ID = 21352;
        private final int MODEL_COMPONENT_ID = 21377;
        private int[] rewards = {18985, 21812, 21813, 21814, 19901, 21694, 21868, 18782, 21692};
        private int[] rares = {21877, 5079, 3914, 21691, 19101, 4777, 3912};
        private int itemId;
    
    
        private final Player player;
        //unused for now
        private final int segments = 10;
        private final SecureRandom secureRandom = new SecureRandom();
    
        private WheelOfFortuneGame game = null;
    
        public WheelOfFortune(Player player) {
            this.player = player;
        }
    
        public void open(int[] normalRewards, int[] rareRewards, int itemId) {
            this.rewards = normalRewards;
            this.rares = rareRewards;
            this.itemId = itemId;
            player.getPacketSender().sendInterface(INTERFACE_ID);
            player.getPacketSender().updateInterfaceVisibility(21370, false);
            player.getPacketSender().updateInterfaceVisibility(21362, false);
        }
    
        public void start() {
            if(!player.getInventory().contains(itemId)) {
                return;
            }
            if (game != null) {
                player.sendMessage("@red@The wheel is already spinning, wait for it to finish before spinning again");
                return;
            }
            initGame();
        }
    
        private void initGame() {
            List<Integer> left = Arrays.stream(rewards).boxed().collect(Collectors.toList());
            int[] result = Stream.iterate(0, Integer::intValue)
                    .limit(rewards.length)
                    .mapToInt(i -> left.remove(secureRandom.nextInt(left.size())))
                    .toArray();
    
            int randomRare = rares[secureRandom.nextInt(rares.length)];
            int[] newRewards = new int[segments];
            System.arraycopy(result, 0, newRewards, 0, result.length);
            newRewards[newRewards.length - 1] = randomRare;
            game = new WheelOfFortuneGame(newRewards);
            player.getPacketSender()
                    .initWheelOfFortune(WHEEL_INTERFACE_ID, game.getWinningIndex(), game.getItems());
            player.getInventory().delete(itemId, 1);
    
    
        }
    
        public void onFinish(int index) {
            if (index != game.getWinningIndex()) {
                return;
            }
            player.getPacketSender()
                    .sendInterfaceItemModel(MODEL_COMPONENT_ID, game.getReward().getId());
            player.getPacketSender().updateInterfaceVisibility(21370, true);
            player.getPacketSender().updateInterfaceVisibility(21362, true);
            player.getInventory().add(game.getReward());
            game = null;
        }
    }
    Code:
    public class WheelOfFortuneGame {
    
        private final int[] items;
        private final int winningIndex;
    
        public WheelOfFortuneGame(int[] items) {
            this.items = items;
            this.winningIndex = new SecureRandom().nextInt(items.length);
        }
    
        public int[] getItems() {
            return items;
        }
    
        public int getWinningIndex() {
            return winningIndex;
        }
    
        public Item getReward() {
            return new Item(items[winningIndex]);
        }
    }
    Sprites: https://www.mediafire.com/file/5qips...rites.zip/file
    Credit to Herb for the sprites
    Obviously i didn't include every single part, but those take 5mins to add at most
    reupload sprites?
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 1
    Last Post: 01-20-2018, 11:50 PM
  2. Wheel of Fortune
    By Ghost in forum Show-off
    Replies: 19
    Last Post: 10-23-2017, 03:53 PM
  3. hello everyone i need add wheel of fortune
    By mini-max213 in forum Help
    Replies: 0
    Last Post: 05-11-2015, 09:11 PM
  4. Replies: 0
    Last Post: 09-11-2013, 08:43 PM
  5. Wheel of Fortune - I'm With Stupid
    By Andy1814 in forum Humor
    Replies: 14
    Last Post: 02-22-2011, 07:12 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •