android 水果老虎机 文档一

Java学习笔记9:模拟老虎机的运转 /** *作者:朱凌风 *日期:2010年6月10日 *天气:晴、热 *功能:模拟老虎机的运转 */  import java.io.*; public class TigerMachine { public static void main(String[] args) {    Machine ma=new Machine(10);  ma.print();  ma.toWork(); }}  阅读详情

运用andrid最基础的sufaceView制作小时候的最爱,水果老虎机过程文档

先来张初始效果图,图片全部来在网络扣图,那个累呀.........

 

整个图型的画法,和转灯的画法

 

// 自定义画法
	private void drawView() {
		try {
			if (sh != null) {
				iCanvas = sh.lockCanvas();// 获取画布
				// 设置画笔和位图没有锯齿
				iCanvas.setDrawFilter(new PaintFlagsDrawFilter(0,
						Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
				// 背景bg
				iCanvas.drawBitmap(bitmap_bg, null, new RectF(0, 0,
						screenWidth, screenHeight), null);
				// 得分条-win
				iCanvas.drawBitmap(bitmap_score_win, null, new RectF(margin, 0,
						margin + checkWidth * 3, checkWidth), null);
				iCanvas.drawText("" + winOddsScore,
						margin + checkWidth * 3 - 5, checkWidth - checkWidth
								/ 7, iPaint_score);
				// 现在分数条-credit
				iCanvas.drawBitmap(bitmap_score_credit, null, new RectF(margin
						+ checkWidth * 4, 0, margin + checkWidth * 7,
						checkWidth), null);
				iCanvas.drawText("" + creditNum, margin + checkWidth * 7 - 5,
						checkWidth - checkWidth / 7, iPaint_score);

				//画top正方型
				for (int i = 0; i < 7; i++) {
					RectF rectTop = new RectF(margin + i * checkWidth,
							checkWidth, margin + checkWidth + i * checkWidth,
							checkWidth + checkWidth);
					iCanvas.drawBitmap(Content.getTopBitmaps()[i], null,
							rectTop, null);
				}

				// 画right正方型
				for (int i = 1; i < 6; i++) {
					RectF rectRight = new RectF(margin + checkWidth * 6, i
							* checkWidth + checkWidth, margin + checkWidth * 7,
							checkWidth + i * checkWidth + checkWidth);
					iCanvas.drawBitmap(Content.getRightBitmaps()[i - 1], null,
							rectRight, null);
				}

				// 画bottom正方型
				for (int i = 0; i < 7; i++) {
					RectF rectBottom = new RectF(margin + i * checkWidth,
							checkWidth * 6 + checkWidth, margin + checkWidth
									+ i * checkWidth, checkWidth * 7
									+ checkWidth);
					iCanvas.drawBitmap(Content.getBottomBitmaps()[i], null,
							rectBottom, null);
				}
				// 画left正方型
				for (int i = 1; i < 6; i++) {
					RectF rectLeft = new RectF(margin, i * checkWidth
							+ checkWidth, margin + checkWidth, checkWidth + i
							* checkWidth + checkWidth);
					iCanvas.drawBitmap(Content.getLeftBitmaps()[i - 1], null,
							rectLeft, null);
				}
				// 移动的发光图标
				if (isOk) {
					if (num < randomNum) {// 每次刷屏num+1;当比随机出来的转数小时,继续转,当大于等于时就停止
						if (num < (randomNum / 13)) {// 控件转灯的速度,由慢-快-慢
							sleepNum = 300;
						} else if (num < (randomNum * 2 / 13)) {
							sleepNum = 200;
						} else if (num < (randomNum * 3 / 13)) {
							sleepNum = 100;
						} else if (num < (randomNum * 4 / 13)) {
							sleepNum = 80;
						} else if (num < (randomNum * 5 / 13)) {
							sleepNum = 50;
						} else if (num < (randomNum * 6 / 13)) {
							sleepNum = 20;
						} else if (num < (randomNum * 7 / 13)) {
							sleepNum = 10;
						} else if (num < (randomNum * 8 / 13)) {
							sleepNum = 20;
						} else if (num < (randomNum * 9 / 13)) {
							sleepNum = 50;
						} else if (num < (randomNum * 10 / 13)) {
							sleepNum = 80;
						} else if (num < (randomNum * 11 / 13)) {
							sleepNum = 100;
						} else if (num < (randomNum * 12 / 13)) {
							sleepNum = 200;
						} else {
							sleepNum = 300;
						}
						if (num % 1 == 0) {
							if (num < randomNum - 1) {//最后一下声响(啪)的一声
								soundPool.play(dingSound, 1, 1, 1, 0, 1);
							} else if (isPaSound) {
								soundPool.play(paSound, 1, 1, 1, 0, 1);
								isPaSound = false;
							}
							if (countTop < 7) {
								rectSelect = new RectF(margin + countTop
										* checkWidth, checkWidth, margin
										+ checkWidth + countTop * checkWidth,
										checkWidth + checkWidth);
								iCanvas.drawBitmap(bitmap_sifangkuang, null,
										rectSelect, null);
								countTop++;
							} else if (countTop >= 7 && countRight < 6) {
								rectSelect = new RectF(margin + 6 * checkWidth,
										countRight * checkWidth + checkWidth,
										margin + checkWidth * 7, checkWidth
												+ countRight * checkWidth
												+ checkWidth);
								iCanvas.drawBitmap(bitmap_sifangkuang, null,
										rectSelect, null);
								countRight++;
							} else if (countRight >= 6 && countBottom >= 0) {
								rectSelect = new RectF(margin + countBottom
										* checkWidth, checkWidth * 6
										+ checkWidth, margin + checkWidth
										+ countBottom * checkWidth, checkWidth
										* 7 + checkWidth);
								iCanvas.drawBitmap(bitmap_sifangkuang, null,
										rectSelect, null);
								countBottom--;
							} else if (countBottom < 0 && countLeft > 0) {
								rectSelect = new RectF(margin, checkWidth
										* countLeft + checkWidth, margin
										+ checkWidth, checkWidth * countLeft
										+ checkWidth + checkWidth);
								iCanvas.drawBitmap(bitmap_sifangkuang, null,
										rectSelect, null);
								countLeft--;
							}
							if (countLeft == 0) {// 循环一圈,以左上角0,0为始点
								countTop = 0;
								countRight = 1;
								countLeft = 5;
								countBottom = 6;
							}
						}
						num++;//通过自加,接近随机出来的转运数值
					} else {
						//最后停的一下
						iCanvas.drawBitmap(bitmap_sifangkuang, null,
								rectSelect, null);
						float x = rectSelect.left;
						float y = rectSelect.top;
						// 赔率
						// intBar+intSeven+intStar+intXG+intLD+intMG+intOrange+intApple
						if (isScore) {
							//自定义方法,获取中奖分数
							winOddsScore = Content.getWinOdds(intBar, intSeven,
									intStar, intXG, intLD, intMG, intOrange,
									intApple, margin, checkWidth, x, y);
						}
						//System.out.println("中奖分数=" + winOddsScore);
						if (isStart) {// 按了go开始进入
							if (winOddsScore == 0) {//没中奖,清0
								cleanAllNum();
							}
						}
						isStart = false;
						sleepNum = 100;//运气run的sleep时间

					}
				}

				RectF rectBottom_1 = new RectF(margin, checkWidth * 7
						+ checkWidth, screenWidth - margin, checkWidth * 8
						+ checkWidth);
				iCanvas.drawBitmap(bitmap_bottom_1, null, rectBottom_1, null);

				RectF rectBottom_2 = new RectF(margin, checkWidth * 8
						+ checkWidth, screenWidth - margin, checkWidth * 8
						+ checkWidth / 2 + checkWidth);
				// iCanvas.drawBitmap(bitmap_bottom_2, null, rectBottom_2,
				// null);

				RectF rectBottom_3 = new RectF(margin, checkWidth * 9
						+ checkWidth / 2, screenWidth - margin, checkWidth * 11);
				iCanvas.drawBitmap(bitmap_bottom_3, null, rectBottom_3, null);

				iCanvas.drawText(stringBar, margin + chipNumWidth / 4,
						checkWidth * 8 + checkWidth * 2 / 5 + checkWidth,
						iPaint);
				iCanvas.drawText(stringSeven, margin + chipNumWidth
						+ chipNumWidth / 5, checkWidth * 8 + checkWidth * 2 / 5
						+ checkWidth, iPaint);
				iCanvas.drawText(stringStar, margin + chipNumWidth * 2
						+ chipNumWidth / 5, checkWidth * 8 + checkWidth * 2 / 5
						+ checkWidth, iPaint);
				iCanvas.drawText(stringXG, margin + chipNumWidth * 3
						+ chipNumWidth / 6, checkWidth * 8 + checkWidth * 2 / 5
						+ checkWidth, iPaint);
				iCanvas.drawText(stringLD, margin + chipNumWidth * 4
						+ chipNumWidth / 6, checkWidth * 8 + checkWidth * 2 / 5
						+ checkWidth, iPaint);
				iCanvas.drawText(stringMG, margin + chipNumWidth * 5
						+ chipNumWidth / 6, checkWidth * 8 + checkWidth * 2 / 5
						+ checkWidth, iPaint);
				iCanvas.drawText(stringOrange, margin + chipNumWidth * 6
						+ chipNumWidth / 7, checkWidth * 8 + checkWidth * 2 / 5
						+ checkWidth, iPaint);
				iCanvas.drawText(stringApple, margin + chipNumWidth * 7,
						checkWidth * 8 + checkWidth * 2 / 5 + checkWidth,
						iPaint);

			}
		} catch (Exception e) {
		} finally {
			if (iCanvas != null) {
				sh.unlockCanvasAndPost(iCanvas);// 解锁画布并提交
			}
		}

	}


 

自定义获取中奖分数的方法

//传进来中奖的坐标,返回中奖的赔率和中奖的水果
	public static int getWinOdds(int intBar,int intSeven,int intStar,int intXG,int intLD,int intMG,int intOrange,int intApple,float margin,float checkWidth,float x,float y){
//		System.out.println("intBar="+intBar);
//		System.out.println("intSeven="+intSeven);
		int winOdds[] = new int[2];
		int winOddsScroe = 0;
		
		if(y==checkWidth){//top
			switch ((int)((x-margin)/checkWidth)) {
			case 0:
				winOdds[0] = 10;
				winOdds[1] = 1;
				break;
			case 1:
				winOdds[0] = 20;
				winOdds[1] = 3;
				break;
			case 2:
				winOdds[0] = 25;
				winOdds[1] = 7;
				break;
			case 3:
				winOdds[0] = 50;
				winOdds[1] = 7;
				break;
			case 4:
				winOdds[0] = 5;
				winOdds[1] = 0;
				break;
			case 5:
				winOdds[0] = 2;
				winOdds[1] = 0;
				break;
			case 6:
				winOdds[0] = 15;
				winOdds[1] = 2;
				break;

			default:
				break;
			}
		}
		if((x-margin)/6==checkWidth){
			switch ((int)(y/checkWidth)) {
			case 2:
				winOdds[0] = 20;
				winOdds[1] = 4;
				break;
			case 3:
				winOdds[0] = 2;
				winOdds[1] = 4;
				break;
			case 4:
				winOdds[0] = -1;
				winOdds[1] = -1;
				break;
			case 5:
				winOdds[0] = 5;
				winOdds[1] = 0;
				break;
			case 6:
				winOdds[0] = 2;
				winOdds[1] = 1;
				break;

			default:
				break;
			}
		}
		if(y==checkWidth*7){
			switch ((int)((x-margin)/checkWidth)) {
			case 0:
				winOdds[0] = 15;
				winOdds[1] = 2;
				break;
			case 1:
				winOdds[0] = 2;
				winOdds[1] = 2;
				break;
			case 2:
				winOdds[0] = 5;
				winOdds[1] = 0;
				break;
			case 3:
				winOdds[0] = 40;
				winOdds[1] = 6;
				break;
			case 4:
				winOdds[0] = 2;
				winOdds[1] = 6;
				break;
			case 5:
				winOdds[0] = 20;
				winOdds[1] = 3;
				break;
			case 6:
				winOdds[0] = 10;
				winOdds[1] = 1;
				break;

			default:
				break;
			}
		}
		if(x==margin){
			switch ((int)(y/checkWidth)) {
			case 2:
				winOdds[0] = 2;
				winOdds[1] = 3;
				break;
			case 3:
				winOdds[0] = 5;
				winOdds[1] = 0;
				break;
			case 4:
				winOdds[0] = -2;
				winOdds[1] = -2;
				break;
			case 5:
				winOdds[0] = 2;
				winOdds[1] = 5;
				break;
			case 6:
				winOdds[0] = 30;
				winOdds[1] = 5;
				break;

			default:
				break;
			}
		}
		//intBar+intSeven+intStar+intXG+intLD+intMG+intOrange+intApple
		switch (winOdds[1]) {
		case 0:
			winOddsScroe = intApple * winOdds[0];
			break;
		case 1:
			winOddsScroe = intOrange * winOdds[0];
			break;
		case 2:
			winOddsScroe = intMG * winOdds[0];
			break;
		case 3:
			winOddsScroe = intLD * winOdds[0];
			break;
		case 4:
			winOddsScroe = intXG * winOdds[0];
			break;
		case 5:
			winOddsScroe = intStar * winOdds[0];
			break;
		case 6:
			winOddsScroe = intSeven * winOdds[0];
			break;
		case 7:
			winOddsScroe = intBar * winOdds[0];
			break;

		default:
			break;
		}
		
		return winOddsScroe;
		
	}


 

暂时做到这,实现了压注,开始游戏,中奖获取分数,暂时不能重复上次的压注,每运行一次,都会把压注和得分清0

还没有做赌大小等功能

上下文老虎机:从A/B测试到实时个性化实验的范式升级 上下文老虎机(Contextual Bandits)是一种融合强化学习与在线决策的智能实验范式,其核心在于将传统A/B测试的群体均值比较,升级为基于用户实时特征(如行为、设备、时段)的个体化动作选择。它通过动态平衡探索与利用,在毫秒级完成策略映射,显著降低信息损耗与机会成本。相比静态分组实验,该技术更契合推荐系统、广告出价、内容分发等高频、强上下文依赖场景,已成为现代机器学习工程中‘实验即服务’(EaaS)的关键基础设施。本文聚焦其原理落地、特征设计与生产级实践,尤其解析线性模型起步、汤普森采样与双缓冲更新 阅读详情

相关推荐

Android老虎机开发实战:状态管理、概率控制与滚动动画

在移动应用开发中,状态管理是保证界面一致性的核心问题,尤其在游戏类应用里,界面频繁变化且需要处理异步回调。Android架构组件中的ViewModel能有效隔离界面销毁与数据持有,避免旋转屏幕或进程回收导致的状态丢失。而涉及随机奖励时,均匀随机往往带来糟糕的体验,通过加权随机算法可以精确控制中奖概率,结合可测试的规则类,让赔率设计更合理。列表滚动动画则借助RecyclerView的平滑滚动和插值器实现逼真的转轮效果,兼顾性能和流畅度。此外,数据持久化可使用轻量级SharedPreferences存储玩家进度

weixin_31856057的博客 156

js水果老虎机游戏.zip

有兴趣刚需的可以自己下载,非常实用的代码,可以完美运行,有能力的还可以二次修改!

Android老虎机课设实战:状态机与Handler动画同步

在Android应用开发中,状态机是管理复杂交互流程的核心设计模式,能够有效避免动画播放、用户点击和资金变动之间的状态冲突。同时,Handler机制通过消息队列实现主线程的帧级动画驱动,保证轮播流畅且生命周期安全。SharedPreferences则提供了轻量级数据持久化方案,确保金币余额在Activity重建后仍然一致。这些基础技术广泛运用于游戏、表单校验和支付流程等场景。本文以Android老虎机课程设计为例,从状态转换表、权重随机、Handler轮播动画到金币存取逻辑,完整演示如何将状态机、动画驱动与

weixin_29164185的博客 217

Android UI 实现老虎机详解及实例代码

主要介绍了Android UI 实现老虎机详解及实例代码的相关资料,需要的朋友可以参考下

Android老虎机课程设计:状态机与RecyclerView滚轮实现

状态机是Android交互逻辑中控制复杂UI状态迁移的核心思想,它将用户操作、业务规则与界面反馈解耦,避免多布尔标记引发的状态混乱。RecyclerView作为高性能列表组件,不仅用于常规列表展示,还能借助其复用机制和滚动控制能力,实现无限循环滚轮等自定义视觉效果。结合概率模型与自定义插值器,开发者可以在Android平台上构建具备真实物理手感的老虎机游戏。本文从状态机的基本概念出发,分析其在点击互锁、滚动停止判定等场景中的应用;随后探讨RecyclerView在模拟滚轮时的定位对齐与动画驱动技术,并融入工

weixin_29161785的博客 191

易语言水果机源码

类似老虎机子的水果机源码,主要用于学习,这样更让人学习

android 老虎机实现

最近一直在看波场的小游戏,自己试着手动搞了个老虎机。 先上效果:  主要有两个效果,一个滚轮型,另一种是转盘的。 1:滚轮型      主要是左中右三个滚轮,我这里没有用wheelView来实现,直接用了recyclerview主要实现了下效果,没有太细节的大家包含。滚轮型效果是左侧滚轮停下后,中间和右侧的逐渐停止,右边的最后停下。 public void onStartClick...

赵航的博客 3925

H5 仿android接水果小游戏源代码.rar

一款由HTML5 技术仿写的android接水果小游戏源代码,自己写的,自认为效果还不错,主要是用了很多小图片来修饰画面效果。通过这个小游戏的编写让我学习到了很多HTML5编写技巧,这个游戏玩起来也是很过瘾的,尤其是界面比较漂亮,操作方便支持鼠标,当然在手机上的话就用手触屏了,背着拖框接到上边掉下来的水果,每接到一个都会给一定分值的,比较休闲了,游戏运行界面效果:如下图示。

手把手教你用原生JS/Vue/React实现水果老虎机(80后情怀之作)

项目体验地址 免费视频教程 分别使用原生JS,Vue和React,手把手教你开发一个H5小游戏,快速上手Vue和React框架的使用。 项目截图 在线体验 在线体验 游戏介绍 幸运水果机是一款街机游戏,游戏界面由24个方格拼接成一个正方形,每个方格中都有一个不同的水果图形,方格下都有一个小灯。玩家使用游戏币选择希望押注的目标,按下开始后,小灯开始绕着正方形中每个格子转。当小灯停下时,如果停在玩家押注的目标上则可赢取相应的游戏币。 物品:游戏中的物品有八种,分别为:苹果、西瓜、木瓜、橙子、铃铛、77、双星,

douyh的专栏 5119

HTML5 jquery仿水果老虎机抽奖特效代码.rar

HTML5 jquery仿水果老虎机抽奖特效代码,jquery的调用引入的是jquery-1.11.1.min.js版本,模拟出完全 动感十足的网页在线抽奖动画,和水果机的形式是一模一样的,修改一上,可为你的网站增加一个这种类似的抽奖功能。   本代码在兼容HTML5的浏览器中效果更佳,比如Chrome或火狐或IE10 。

Android应用源码水果老虎机的完整项目带音效

本项目是一个基于安卓的水果老虎机游戏源码,初始的时候会有一些积分,如果积分用完了就需要购买积分,目前积分模式是输入管理员密码就可以加分。默认的管理员密码是javaapk。另外还有一个按钮是可以直接唤起QQ通过手机QQ联系作者的按钮,我保留了。感兴趣的可以自己看一下。

Android简易老虎机(转动式)

说起老虎机,玩过的人应该记得这种类型的图(这是主界面),下面就从最基本的知识分析整个APP的制作过程,也同时把android中的一些基础知识巩固一遍                首先说一下这个APP的基本操作:        1.点击下注按钮后,会进入下注界面            2.上下拖动选择下注比,并选择固定金额或自己输入金额,点击确定返回主界面

小小程序 7384

水果机游戏源码

这是一款水果机的游戏源码,可以直接用,希望能帮到你们。

盘点40个Android游戏Game源码安卓爱好者不容错过

盘点40个Android游戏Game源码安卓爱好者不容错过

zy19830907的博客 1814

安卓老虎机动画效果

模拟老虎机实现安卓动画,通过WheelView实现,添加了屏幕适配工具,当下比较冷门的pt适配

深入解析TPS53676 AVSBus接口:协议、帧结构与动态电压调节实战

在数字电源管理领域,动态电压调节(DVS)是实现高性能处理器(如CPU、GPU)节能与性能优化的关键技术。其核心原理在于根据处理器负载实时、精准地调整供电电压,从而在满足性能需求的同时最小化功耗。为实现微秒甚至纳秒级的快速响应,传统的PMBus协议因其协议开销可能成为瓶颈,因此催生了更专注、更低延迟的专用通信接口。AVSBus(自适应电压调节总线)正是PMBus规范中专为点对点、高速电压控制而定义的子集,它继承了PMBus的物理层,但简化了通信流程,其技术价值在于为处理器与电源控制器之间建立了一条高速“专用

weixin_29188043的博客 445
上一篇: 天龙txt阅读器
下一篇: 怎么导入vitamio并能在自己的程序中使用
bilichen006
博客等级 码龄12年 93粉丝 66原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值