http://jsfiddle.net/goldrunt/jGL84/42/ 这是来自这个JS小提琴的第84行.通过取消注释线141-146,可以对球施加3种不同的效果.'反弹'效果可以正常工作,但'asplode'效果无效.我应该在asplode函数中包含'shrink'函数吗?
// balls shrink and disappear if they touch
var shrink = function(p) {
for (var i = 0; i < 100; i++) {
p.radius -= 1;
}
function asplode(p) {
setInterval(shrink(p),100);
balls.splice(p, 1);
}
}
Run Code Online (Sandbox Code Playgroud) 这个Flask控制器的字典
projects = {
'life-calc':{'url':'life-calc',
'title': 'Life Calculator'},
'text-game':{'url':'text-game',
'title':'Text Adventure'},
'fill-it-up':{'url':'fill-it-up',
'title':'Fill It Up'},
'rock-paper-scissors':{'url':'rock-paper-scissors',
'title':'Rock, Paper, Scissors'},
'bubble-popper':{'url':'bubble-popper',
'title':'Bubble Popper'}
}
@app.route('/')
def index():
return render_template("index.html",
projects = projects)
Run Code Online (Sandbox Code Playgroud)
和模板本身
<h1>
List of My Projects
</h1>
<ol>
<li>
<a href = "life-calc">Life Calculator</a>
</li>
<li>
<a href = "text-game">Adventure Game</a>
</li>
<li>
<a href = "fill-it-up">Fill It Up</a>
</li>
<li>
<a href = "rock-paper-scissors">Rock Paper Scissors</a>
</li>
<li>
<a href = "bubble-popper">Bubble Popper</a>
</li>
</ol>
<p>test section below</p> …Run Code Online (Sandbox Code Playgroud) Ruby初学者努力将这个@@ people hash的值打印到控制台
class Person
#have a first_name and last_name attribute with public accessors
attr_accessor :first_name
attr_accessor :last_name
#have a class attribute called `people` that holds an array of objects
@@people = []
#have an `initialize` method to initialize each instance
def initialize( first_name, last_name )#should take 2 parameters for first_name and last_name
#assign those parameters to instance variables
@first_name = first_name
@last_name = last_name
#add the created instance (self) to people class variable
@@people.push self
end
#have a `search` …Run Code Online (Sandbox Code Playgroud)