谷歌Chrome小恐龙代码(转载)

版权声明:本文为「FriendBoat」原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:[https://blog.csdn.net/Oct10_traitor/article/details/128285387](https://blog.csdn.net/Oct10_traitor/article/details/128285387)

大多数浏览器都有自己的彩蛋,而今天我们分享的是谷歌Chrome

谷歌小恐龙游戏是一个浏览器自带的小游戏。
断网联网状态都是可以玩的
那么如何在联网的状态下进行游戏呢?

首先打开谷歌Chrome,在地址栏输入:chrome://dino/

开整

按Ctrl+Shift+l键或直接打开 开发者工具

自动跳代码:
 function TrexRunnerBot() {
 const makeKeyArgs = (keyCode) => {
 const preventDefault = () => void 0; return {keyCode, preventDefault}; };
 const upKeyArgs = makeKeyArgs(38); const downKeyArgs = makeKeyArgs(40); const startArgs = makeKeyArgs(32);
 if (!Runner().playing) { 
 Runner().onKeyDown(startArgs); setTimeout(() => {
 Runner().onKeyUp(startArgs); }, 500); }
 function conquerTheGame() {
 if (!Runner || !Runner().horizon.obstacles[0]) return;
 const obstacle = Runner().horizon.obstacles[0];
 if (obstacle.typeConfig && obstacle.typeConfig.type === 'SNACK') return;
 if (needsToTackle(obstacle) && closeEnoughToTackle(obstacle)) tackle(obstacle); }
 function needsToTackle(obstacle) {
 return obstacle.yPos !== 50; }
 function closeEnoughToTackle(obstacle) {
 return obstacle.xPos <= Runner().currentSpeed * 18; }
 function tackle(obstacle) {
 if (isDuckable(obstacle)) {
 duck(); } else {
 jumpOver(obstacle); }
 }
 function isDuckable(obstacle) {
 return obstacle.yPos == 75; }
 function duck() {
 drop(); Runner().onKeyDown(downKeyArgs);
 setTimeout(() => {
 Runner().onKeyUp(downKeyArgs); }, 500); }
 function drop() {
 Runner().onKeyDown(downKeyArgs);
 Runner().onKeyUp(downKeyArgs); }
 function jumpOver(obstacle) {
 if (isNextObstacleCloseTo(obstacle))
 jumpFast(); else
 Runner().onKeyDown(upKeyArgs); }
 function isNextObstacleCloseTo(currentObstacle) {
 const nextObstacle = Runner().horizon.obstacles[1];
 return nextObstacle && nextObstacle.xPos - currentObstacle.xPos <=
Runner().currentSpeed * 42; }
 function jumpFast() {
 Runner().onKeyDown(upKeyArgs); Runner().onKeyUp(upKeyArgs); }
 return {conquerTheGame: conquerTheGame}; }
let bot = TrexRunnerBot(); let botInterval = setInterval(bot.conquerTheGame, 2);
无敌代码:
Runner.instance_.gameOver=function(){} 
高跳代码(可以改括号内参数):
Runner.instance_.tRex.setJumpVelocity(20)
疾跑代码(可以改括号内参数):
Runner.instance_.setSpeed(50) 
大家都明白了吗,有问题到评论区评论哦~

快在信息课的时候给别人炫耀炫耀吧

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 Chrome恐龙游戏的 C 语言实现,可以在控制台中运行: ```c #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h> #define WIDTH 50 #define HEIGHT 10 int score = 0; int speed = 100; void clrscr() { system("cls"); } void gotoxy(int x, int y) { COORD pos = {x, y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } void draw(int x, int y) { gotoxy(x, y); printf("*"); } void erase(int x, int y) { gotoxy(x, y); printf(" "); } void print_score() { gotoxy(WIDTH + 5, 1); printf("Score: %d", score); } void print_speed() { gotoxy(WIDTH + 5, 2); printf("Speed: %d", speed); } int main() { int dino_x = 10; int dino_y = HEIGHT - 2; int obs_x = WIDTH; int obs_y = dino_y; int jump = 0; clrscr(); while (1) { // draw dino draw(dino_x, dino_y); // draw obstacle erase(obs_x, obs_y); if (obs_x == 1) { obs_x = WIDTH; score += 10; if (score % 50 == 0 && speed > 10) { speed -= 10; } } else { draw(obs_x, obs_y); obs_x--; } // print score and speed print_score(); print_speed(); // check collision if (dino_x == obs_x && dino_y == obs_y) { break; } // jump if (_kbhit()) { char c = _getch(); if (c == ' ') { jump = 1; } } if (jump == 1) { dino_y--; } else { if (dino_y < HEIGHT - 2) { dino_y++; } } if (jump == 1 && dino_y == HEIGHT - 5) { jump = 0; } // delay Sleep(speed); } clrscr(); printf("Game Over! Score: %d", score); return 0; } ``` 该代码实现了一个简单的控制台小游戏,玩家需要控制小恐龙躲避障碍物,直到碰到障碍物游戏结束。玩家可以通过空格键使小恐龙跳跃,得分会随着时间的推移而增加,游戏难度也会随之增加。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值