如果你是零基础入门 Python 的话,建议初学者至少达到两个目标: 会用,理解。

会用

通过 Python 入门教程,学习 Python 的语法,熟悉 Python 标准库的使用。

目前 Python 官方已经发布了中文版的官方教程,降低了学习 Python 的门槛。建议初学者一开始直接从 Python 官方教程开始学习 Python。

通过 Python 官方教程,学习 Python 的语法,熟悉 Python 标准库的使用。

目前 Python 官方已经发布了中文版的官方教程,降低了学习 Python 的门槛。建议初学者一开始直接从 Python 官方教程开始学习 Python。

理解

程序这个东西,即使你一知半解,也是可以跑的通的。但是这样的学习效果不是我们想要的。程序能运行,不代表你学会了。所以,不管是学习 Python,还是其他语言,理解程序是最重要的,理解了程序,才能学会。

初学者可以通过 Python Tutor ,直接在 Web 浏览器中编写 Python 代码,可视化地运行程序。

通过可视化的程序运行步骤,来帮助初学者理解程序,加深对代码的思考。

如果你觉得看文章学习枯燥无味,还可以找 Python 的视频教程来学习。

我这里积累了很多的python干货资料,需要的可以找我来拿

参考下图找我

var GameLayer = cc.Layer.extend({

touchStartX:0,

touchStartY:0,

bullets:[],

enemies:[],

tools:[],

ctor: function () {

this._super();

this.touchStartX = 0;

this.touchStartY = 0;

this.bullets = [];

this.enemies = [];

this.tools = [];

// 播放背景音乐

cc.audioEngine.playMusic("res/sound/game_music.mp3",true);

// 加载plist

cc.spriteFrameCache.addSpriteFrames(res.shoot_background_plist);

cc.spriteFrameCache.addSpriteFrames(res.shoot_plist);

// 添加背景图

var bg = new Background(false);

bg.setPosition(0,0);

this.addChild(bg);

// 添加飞机

var player = new Player(this);

player.setPosition(cc.winSize.width / 2, -player.height / 2);

this.addChild(player);

player.setTag(1);

// 产生敌机

this.schedule(function(){

this.createEnemy(1);

},Global.createEnemySpeed(1));

this.schedule(function(){

this.createEnemy(2);

},Global.createEnemySpeed(2));

this.schedule(function(){

this.createEnemy(3);

},Global.createEnemySpeed(3));

// 产生道具

this.schedule(function(){

this.createTool(1);

},Global.createToolSpeed(1));

this.schedule(function(){

this.createTool(2);

},Global.createToolSpeed(2));

// 添加爆炸道具

var bombNor = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame("bomb.png"));

var bombSelected = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame("bomb.png"));

bombSelected.setPosition(-bombSelected.width/4,-bombSelected.height/4);

bombSelected.setScale(1.5);

var bombBtn = new cc.MenuItemSprite(

bombNor,

bombSelected,

function () {

var bombNum = this.getChildByTag(3);

if(parseInt(bombNum.getString().slice(1))==0){

return;

}

// 全屏爆炸

var blowEnemy = [];

for(var i in this.enemies){

var enemy = this.enemies[i];

blowEnemy.push(enemy);

}

for(var j in blowEnemy){

blowEnemy[j].blowUp();

}

// 数量减一

bombNum.setString("X"+(parseInt(bombNum.getString().slice(1))-1));

}, this);

bombBtn.setPosition(50+bombBtn.width/2,50+bombBtn.height/2);

var bombMenu = new cc.Menu(bombBtn);

bombMenu.setPosition(0,0);

bombMenu.setAnchorPoint(0,0);

this.addChild(bombMenu);

// 爆炸道具数量

var bombNum = new cc.LabelBMFont("X2",res.font);

bombNum.setAnchorPoint(0,0.5);

bombNum.setPosition(bombBtn.getPositionX()+bombBtn.width/2+50,bombBtn.getPositionY());

bombNum.setTag(3);

this.addChild(bombNum);

// 暂停开始按钮

var pauseBtn = new cc.MenuItemSprite(

new cc.Sprite(cc.spriteFrameCache.getSpriteFrame("game_pause_nor.png")),

new cc.Sprite(cc.spriteFrameCache.getSpriteFrame("game_pause_pressed.png")),

function () {

// 暂停音乐音效

cc.audioEngine.pauseAllEffects();

cc.audioEngine.pauseMusic();

pauseBtn.setEnabled(false);

cc.director.pause();

this.addChild(new PauseLayer(pauseBtn),10);

}, this);

var pauseMenu = new cc.Menu(pauseBtn);

pauseMenu.setPosition(20+pauseBtn.width/2,cc.winSize.height-pauseBtn.height/2-20);

pauseMenu.setAnchorPoint(0,0);

this.addChild(pauseMenu);

// 分数

var score = new cc.LabelBMFont("0",res.font);

score.setAnchorPoint(0,0.5);

score.setPosition(pauseMenu.getPositionX()+pauseBtn.width/2+50,pauseMenu.getPositionY());

score.setTag(2);

this.addChild(score);

// 碰撞检测

this.schedule(this.collision);

return true;

},

collision:function(){

var bullets = this.bullets;

var enemies = this.enemies;

var tools = this.tools;

var score = parseInt(this.getChildByTag(2).getString());

for(var i in enemies){

var enemy = enemies[i];

// 检测是否与玩家碰撞

var player = this.getChildByTag(1);

if(cc.rectIntersectsRect(enemy.getBoundingBox(),player.getBoundingBox())){

// 游戏结束

this.unschedule(this.collision);

player.blowUp();

// 停止背景音乐

cc.audioEngine.stopMusic("res/sound/game_music.mp3");

cc.audioEngine.playEffect("res/sound/game_over.mp3");

this.scheduleOnce(function() {

cc.director.runScene(new cc.TransitionFade(1,new OverScene(score)));

},2);

}

// 检测是否吃到道具

for(var m in tools){

var tool = tools[m];

if(cc.rectIntersectsRect(tool.getBoundingBox(),player.getBoundingBox())){

switch(tool.type){

case 1:

// 双排子弹道具

cc.audioEngine.playEffect("res/sound/get_double_laser.mp3");

player.shootDoubleBegin();

break;

case 2:

// 清屏道具

cc.audioEngine.playEffect("res/sound/get_bomb.mp3");

var bomb = this.getChildByTag(3);

bomb.setString("X"+(parseInt(bomb.getString().slice(1))+1));

bomb.runAction(cc.sequence(cc.scaleTo(0.1,1.2),cc.scaleTo(0.1,1)));

break;

}

tool.remove();

}

}

for(var j in bullets){

var bullet = bullets[j];

// 检测是否与子弹碰撞

if(cc.rectIntersectsRect(enemy.getBoundingBox(),bullet.getBoundingBox())){

enemy.hit();

bullet.remove();

}

}

}

},

addScore:function(type){

var score = this.getChildByTag(2);

var addScore = 0;

var curScore = parseInt(score.getString());

switch(type){

case 1:

addScore = 100 + Math.ceil(Math.random()*(curScore/1000));

break;

case 2:

addScore = 200 + Math.ceil(Math.random()*(curScore/1000));

break;

case 3:

addScore = 500 + Math.ceil(Math.random()*(curScore/1000));

break;

}

score.setString(curScore+addScore);

},

createEnemy:function(type){

var enemy = new Enemy(type,this);

var randomX = Math.random()*(cc.winSize.width-enemy.width/2-enemy.width/2)+enemy.width/2;

enemy.setPosition(randomX,cc.winSize.height+enemy.height/2);

this.addChild(enemy);

this.enemies.push(enemy);

},

createTool:function(type){

var tool = new Tool(type,this);

var randomX = Math.random()*(cc.winSize.width-tool.width/2-tool.width/2)+tool.width/2;

tool.setPosition(randomX,cc.winSize.height+tool.height/2);

this.addChild(tool);

this.tools.push(tool);

},

onEnter:function(){

this._super();

// 添加触摸事件

cc.eventManager.addListener({

event:cc.EventListener.TOUCH_ONE_BY_ONE,

swallowTouches:true,

onTouchBegan:this.touchbegan,

onTouchMoved:this.touchmoved,

onTouchEnded:this.touchended

},this);

return true;

},

touchbegan:function(touch,event){

event.getCurrentTarget().touchStartX = touch.getLocation().x;

event.getCurrentTarget().touchStartY = touch.getLocation().y;

return true;

},

touchmoved:function(touch,event){

var touchX = touch.getLocation().x;

var touchY = touch.getLocation().y;

var touchStartX = event.getCurrentTarget().touchStartX;

var touchStartY = event.getCurrentTarget().touchStartY;

var player = event.getCurrentTarget().getChildByTag(1);

if(player!=null){

player.moveBy(touchX-touchStartX,touchY-touchStartY);

event.getCurrentTarget().touchStartX = touchX;

event.getCurrentTarget().touchStartY = touchY;

}

return true;

},

touchended:function(touch,event){

return true;

}

});

高中python教程标准_高中应该怎样自学Python?相关推荐

  1. 微软大神的python语言入门_你是如何自学 Python 的?

    [个人介绍] 本人大学专业为"高分子材料与工程",属化学方向,毫无编程经验,但在18年中由于工作需要处理大量数据,"被迫"学习了数据库和Python,虽然不能算 ...

  2. 学python的总结_为什么那么多自学Python的后来都放弃了,总结起来就这些原因

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 目前信息化产业发展势头很好,互联网就成为了很多普通人想要涉及的行业,因为相比于传统行业,互联网行业涨薪幅度大,机会也多,所以就会大批的人想要转行来学习we ...

  3. 为什么不建议学python贴吧_为什么那么多自学Python的后来都放弃了,总结下来就这些原因...

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 目前信息化产业发展势头很好,互联网就成为了很多普通人想要涉及的行业,因为相比于传统行业,互联网行业涨薪幅度大,机会也多,所以就会大批的人想要转行来学习Py ...

  4. 为什么不建议学python贴吧_为什么那么多自学Python的后来都放弃了,分析起来就这些原因...

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 目前信息化产业发展势头很好,互联网就成为了很多普通人想要涉及的行业,因为相比于传统行业,互联网行业涨薪幅度大,机会也多,所以就会大批的人想要转行来学习Py ...

  5. 420集的python教程下载_清华学霸录制 420集python视频教程给你拿去学!两个月让你变大神...

    Python已经成为一种再主流不过的编程语言了.它天生丽质,易于读写,非常实用,从而赢得广泛的群众基础,被誉为"宇宙最好的编程语言",被无数程序员热烈追捧. 随着时代的发展越来越快 ...

  6. python 惰性序列_菜鸟学飞自学Python(五)高阶函数

    (仅个人学习摘抄) 函数式编程 函数式编程就是一种抽象程度很高的编程范式,特点是允许把函数本身作为参数传入到另一个函数,还允许返回一个函数. 高阶函数 高阶函数--Higher-order funct ...

  7. python做词典_真·0基础自学python(字典)

    前言:字典在很多的教材中都是和列表.元组放在一起说,其中有一本书的安排顺序比较精妙,我这里也是遵循这本书的逻辑过来的. 字典在if 语句的作用下,可以做到Excel表格里Vlookup函数的效果. 看 ...

  8. 自学python困难吗_自学Python会有什么困难?老男孩自学python编程

    学习Python开发的过程中,不少自学Python的小伙伴失败了,Python一直以来都是深受程序员喜爱的编程语言,那么自学Python编程为什么难?Python开发要怎样学呢?其实自学的大问题就是难 ...

  9. python编程自学能学会吗-自学Python会有什么困难?老男孩自学python编程

    学习Python开发的过程中,不少自学Python的小伙伴失败了,Python一直以来都是深受程序员喜爱的编程语言,那么自学Python编程为什么难?Python开发要怎样学呢?其实自学的大问题就是难 ...

  10. python是什么 自学-自学Python会有什么困难?老男孩自学python编程

    学习Python开发的过程中,不少自学Python的小伙伴失败了,Python一直以来都是深受程序员喜爱的编程语言,那么自学Python编程为什么难?Python开发要怎样学呢?其实自学的大问题就是难 ...

最新文章

  1. HDLBits 系列(34)Serial two's complememter(Mealy and Moore FSM)
  2. ABAP 数字处理相关内容备注
  3. Cocoapods的Podfile使用
  4. Tensorflow实现MNIST数据自编码(2)
  5. java.lang.Exception: Socket bind failed: [730048]
  6. leetcode 227. Basic Calculator II | 227. 基本计算器 II(中缀表达式求值)
  7. Codeforces Round #700 (Div. 1Div. 2)
  8. 成功驱动HD4600-Clover引导
  9. 求字符串长度(复习)
  10. WIN7用键盘控制鼠标
  11. java编程实现;猜单词游戏
  12. 编译、汇编、翻译原理知识概括
  13. 世界排名第一的免费开源WMS仓储物流管理系统介绍
  14. Unity打包apk报错: Cannot fit requested classes in a single dex file (# methods: 73376 > 65536)的解决办法
  15. E. The Humanoid
  16. WeWork入华 盈利奇迹能否复制
  17. 多功能可视化搜索引擎3Dfind.it问世,开启零部件搜索新纪元
  18. 【vivado IP核】第4篇:ILA使用介绍
  19. MYSQL索引底层原理
  20. 手机软件开发入门 - 中国象棋(1)090308

热门文章

  1. GEE学习:影像数据集理解与显示
  2. 一款可以直接下载浏览器sources资源的Chrome插件
  3. 如何飞速成为开源贡献者(Contributor)
  4. 【即将截止申报】五大年度榜单颁奖+产业图谱+行业报告,2020年度金猿策划活动正式开启...
  5. USB口13.56MHZ高频M1卡写卡机T6-AU-00-00程序安装步骤
  6. matlab中小波工具箱,Matlab小波工具箱的使用1
  7. php redis使用
  8. [算法]广度优先搜索VS深度优先搜索
  9. 线阵相机调帧率_工业相机帧率下降的原因是什么?
  10. AI:04-基于机器学习的蘑菇分类