##Related free learning recommendations:javascript (Video)
1. Course Outline
String Splicing ( ) Learning and applicationApplication of coordinate transformation in the airplane war game
2.1 String splicing
2.2 Display the number of friends on the warning box
Display the number of friends on the warning box, the display effect is as followsvar friends = 7; alert("我的朋友数量为:" +friends);
2.3 Display your age on the warning box
Declare the variable age and assign it to your age. The code is as follows:var age = 23;
alert("我的年龄" + age);
var score = 95;
var x = 50;
var y = 50;
ctx.font = "30px 微软雅黑";
var score = 95; var x = 50; var y = 50; ctx.font = "30px 微软雅黑"; ctx.fillText("分数:" + score,x,y);
3.1 Changes in coordinates
Observe the picture below. The villain moves from point A to point B. How do the coordinates change?Background and aircraft movement
The coordinate change rule of the background and the aircraft at the same time is: the X coordinate values of the background and aircraft remain unchanged, and the Y coordinate values continue to increase;If you want the aircraft to move faster than the background, then within the same time, the increase value of the Y coordinate of the aircraft is greater than the increase value of the Y coordinate of the background. The codes for background and aircraft movement are as follows (where: x1 and y1 represent the coordinates of the background; x and y represent the coordinates of the aircraft):var x1 = 0; var y1 = 0; var x = 200; var y = 0; setInterval(function(){ ctx.drawImage(background, x1, y1); y1=y1+1; ctx.drawlmage(enemy, x, y); y=y+3; },10);
Related free learning recommendations:php programming (video)
The above is the detailed content of Novice Javascript string concatenation and application of variables. For more information, please follow other related articles on the PHP Chinese website!