How to use block1 method in ng-mocks

Best JavaScript code snippet using ng-mocks

objectUpdate.js

Source:objectUpdate.js Github

copy

Full Screen

1// Update blocks acceleration2// Update position of Block 1 & 2 and angle of Pulley3// according to motion phase4// And detect for collision between Block 2 and Stopper5function objectUpdate() {6 // Update time7 dt = animSpeedSlider.value() / fps;8 t += dt;9 // --------------------------------------------------------------------------10 // Tests to determine static/kinetic motion and if stopper has been reached11 // --------------------------------------------------------------------------12 // Test static hypothesis13 if (staticTest == "on") {14 let fsmax = mus.value() * block1.mass * g;15 if (block2.mass * g <= fsmax) {16 motionState = "static";17 } else {18 motionState = "kinetic";19 }20 staticTest = "off";21 }22 // Test if stopper has been reached23 if (block2.pos.y <= stopper.pos.y + block2.height / 2 + stopper.height) {24 stopperState = "on";25 } else {26 stopperState = "off";27 }28 // --------------------------------------------------------------------------29 // Update forces magnitudes and accelerations30 // --------------------------------------------------------------------------31 Fg1.dir.set(0, -block1.mass * g);32 n1.dir.set(0, block1.mass * g);33 Fg2.dir.set(0, -block2.mass * g);34 switch (motionState) {35 case "static":36 if (stopperState == "off") {37 // No normal on block 238 n2.dir.set(0, 0);39 // T1 = T2 = fsc = Fg240 T1b.dir.set(-Fg2.dir.mag(), 0);41 T1p.dir.set(+Fg2.dir.mag(), 0);42 T2b.dir.set(0, +Fg2.dir.mag());43 T2p.dir.set(0, -Fg2.dir.mag());44 fsc.dir.set(+Fg2.dir.mag(), 0);45 } else if (stopperState == "on") {46 // Normal on block 247 n2.dir.set(0, Fg2.dir.mag());48 // T1 = T2 = fsc = 049 T1b.dir.set(0, 0);50 T1p.dir.set(0, 0);51 T2b.dir.set(0, 0);52 T2p.dir.set(0, 0);53 fsc.dir.set(0, 0);54 }55 block1.acc.set(0, 0);56 block2.acc.set(0, 0);57 break;58 case "kinetic":59 if (stopperState == "off") {60 // No normal on block 261 n2.dir.set(0, 0);62 // T1, T2, fsc63 let mucNum = parseFloat(muc.value());64 let T1 =65 (block1.mass *66 block2.mass *67 g *68 (1 + mucNum + (mucNum * pulley.mass) / (2 + block2.mass))) /69 (block1.mass + block2.mass + pulley.mass / 2);70 let T2 =71 (block1.mass *72 block2.mass *73 g *74 (1 + mucNum + pulley.mass / 2 / block1.mass)) /75 (block1.mass + block2.mass + pulley.mass / 2);76 T1b.dir.set(-T1, 0);77 T1p.dir.set(+T1, 0);78 T2b.dir.set(0, +T2);79 T2p.dir.set(0, -T2);80 fsc.dir.set(mucNum * block1.mass * g, 0);81 block1.acc.set((T1b.dir.x + fsc.dir.x) / block1.mass, 0);82 block2.acc.set(0, (T2b.dir.y + Fg2.dir.y) / block2.mass);83 } else if (stopperState == "on") {84 // Normal on block 285 n2.dir.set(0, block2.mass * g);86 // T1 = T2 = fsc = 087 T1b.dir.set(0, 0);88 T1p.dir.set(0, 0);89 T2b.dir.set(0, 0);90 T2p.dir.set(0, 0);91 let mucNum = parseFloat(muc.value());92 fsc.dir.set(mucNum * block1.mass * g, 0);93 block1.acc.set(fsc.dir.x / block1.mass, 0);94 block2.acc.set(0, (n2.dir.y - block2.mass * g) / block2.mass);95 }96 break;97 }98 // --------------------------------------------------------------------------99 // Update plots100 // --------------------------------------------------------------------------101 // Acceleration plot102 label =103 t.toFixed(2).toString() +104 "s" +105 ", " +106 -block1.acc.x.toFixed(2).toString() +107 "m/s^2";108 plotAcc.points.push(new GPoint(t, -block1.acc.x.toFixed(4), label));109 // Velocity plot block 1110 label =111 t.toFixed(2).toString() +112 "s" +113 ", " +114 -block1.vel.x.toFixed(2).toString() +115 "m/s";116 plotVel.points.push(new GPoint(t, -block1.vel.x.toFixed(4), label));117 // Position plot block 1118 label =119 t.toFixed(2).toString() +120 "s" +121 ", " +122 -(block1.pos.x - block1.posInit.x).toFixed(2).toString() +123 "m";124 plotPos.points.push(125 new GPoint(t, -(block1.pos.x - block1.posInit.x).toFixed(4), label)126 );127 // --------------------------------------------------------------------------128 // Update positions and velocities of block 1, 2 and the pulley129 // --------------------------------------------------------------------------130 // Update block 1, 2 and pulley positions and velocities131 // test if Block 1 has reached the left end (which means end of movement)132 let block1XLimit = pulley.pos.x + block1.width / 2 + 1.5 * pulley.radius;133 if (block1.pos.x >= block1XLimit) {134 block1.pos0 = block1.pos;135 block1.vel0 = block1.vel;136 block1.pos.set(137 block1.pos0.x + block1.vel0.x * dt + 0.5 * block1.acc.x * dt * dt,138 block1.pos0.y + block1.vel0.y * dt + 0.5 * block1.acc.y * dt * dt139 );140 block1.vel.set(141 block1.vel0.x + block1.acc.x * dt,142 block1.vel0.y + block1.acc.y * dt143 );144 pulley.angle0 = pulley.angle;145 pulley.angle =146 pulley.angle0 +147 (block1.vel.x / pulley.radius) * dt +148 ((0.5 * block1.acc.x) / pulley.radius) * dt * dt;149 } else {150 block1.pos.x = block1XLimit;151 block1.vel.x = 0;152 simPhase = "pause";153 }154 // Test if Block 1 velocity has reach zero155 if (block1.vel.x >= 0) {156 block1.vel.x = 0;157 simPhase = "pause";158 }159 // Test if Block 2 has reached the stopper160 if (stopperState == "off") {161 block2.pos0 = block2.pos;162 block2.vel0 = block2.vel;163 block2.pos.set(164 block2.pos0.x + block2.vel0.x * dt + 0.5 * block2.acc.x * dt * dt,165 block2.pos0.y + block2.vel0.y * dt + 0.5 * block2.acc.y * dt * dt166 );167 block2.vel.set(168 block2.vel0.x + block2.acc.x * dt,169 block2.vel0.y + block2.acc.y * dt170 );171 } else if (stopperState == "on") {172 block2.pos.y = stopper.pos.y + block2.height / 2 + stopper.height;173 block2.vel.y = 0;174 }175 // --------------------------------------------------------------------------176 // Update forces positions177 // --------------------------------------------------------------------------178 Fg1.pos.set(block1.pos.x, block1.pos.y);179 n1.pos.set(block1.pos.x, block1.pos.y);180 Fg2.pos.set(block2.pos.x, block2.pos.y);181 n2.pos.set(block2.pos.x, block2.pos.y);182 T1b.pos.set(block1.pos.x, block1.pos.y);183 T1p.pos.set(pulley.pos.x, pulley.pos.y + pulley.radius);184 T2b.pos.set(block2.pos.x, block2.pos.y);185 T2p.pos.set(pulley.pos.x - pulley.radius, pulley.pos.y);186 fsc.pos.set(block1.pos.x, block1.pos.y);...

Full Screen

Full Screen

BlockListener.js

Source:BlockListener.js Github

copy

Full Screen

1//Block listener.2var BlockListener = function(game){3 this.currentGame = game;4};5BlockListener.prototype.begin = function(arbiter, space){6 7 var block1 = null;8 var block2 = null;9 10 if(arbiter.body_a.userdata != null && arbiter.body_a.userdata.type == Enum.UserData.Type.BLOCK)11 block1 = arbiter.body_a.userdata.object;12 if(arbiter.body_b.userdata != null && arbiter.body_b.userdata.type == Enum.UserData.Type.BLOCK)13 block2 = arbiter.body_b.userdata.object;14 15 //Resolve skill.16 if(block1 != null && block1.type == Enum.Block.Type.SKILLED && block1.skill != null)17 this.resolve(block1, arbiter.body_b.userdata);18 19 if(block2 != null && block2.type == Enum.Block.Type.SKILLED && block2.skill != null)20 this.resolve(block2, arbiter.body_a.userdata);21 //Special process for collision with two blocks.22 if(block1 != null && block2 != null)23 { 24 //Some skills need a target defined when touching a block.25 if(block1.skill && block1.skill.targetWithBlock)26 block1.linkedBlockId = block2.id;27 28 if(block2.skill && block2.skill.targetWithBlock)29 block2.linkedBlockId = block1.id;30 31 if(block1.type == Enum.Block.Type.COLORED && block2.type == Enum.Block.Type.COLORED32 && block1.color == block2.color && block1.color < Enum.Color.GREEN)33 { 34 //Check if linked block has been destroyed first.35 if(block1.linkedBlockId != null && this.currentGame.blocks[block1.linkedBlockId] == null)36 block1.linkedBlockId = null;37 if(block2.linkedBlockId != null && this.currentGame.blocks[block2.linkedBlockId] == null)38 block2.linkedBlockId = null;39 40 //If blocks are touching a third one, destroy them all.41 if((block1.linkedBlockId != null && block1.linkedBlockId != block2.id) 42 || (block2.linkedBlockId != null && block2.linkedBlockId != block1.id))43 {44 block1.markToDestroy(Enum.Block.Destruction.COLOR_CONTACT);45 block2.markToDestroy(Enum.Block.Destruction.COLOR_CONTACT);46 47 //Destroy linked leaves.48 if(block1.linkedBlockId != null)49 this.destroyLeaves(block1.linkedBlockId, block1.id);50 if(block2.linkedBlockId != null)51 this.destroyLeaves(block2.linkedBlockId, block2.id);52 53 block1 = null;54 block2 = null;55 }56 else57 {58 block1.linkedBlockId = block2.id;59 block2.linkedBlockId = block1.id;60 }61 }62 else if(block1.type == Enum.Block.Type.COLORED && block2.type == Enum.Block.Type.COLORED 63 && Math.abs(block1.color - block2.color) == 4)64 {65 //Destroy complementary blocks on contact.66 block1.markToDestroy(Enum.Block.Destruction.COLOR_CONTACT);67 block2.markToDestroy(Enum.Block.Destruction.COLOR_CONTACT);68 69 block1 = null;70 block2 = null;71 }72 }73 74 //Treament for player within contact.75 var player = null;76 77 if(block1 == null && arbiter.body_a.userdata != null && arbiter.body_a.userdata.type == Enum.UserData.Type.PLAYER)78 player = arbiter.body_a.userdata.object;79 if(block2 == null && arbiter.body_b.userdata != null && arbiter.body_b.userdata.type == Enum.UserData.Type.PLAYER)80 player = arbiter.body_b.userdata.object;81 82 //Trigger spawn.83 if(block1 != null && player == null && block1.type == Enum.Block.Type.SPAWN)84 block1.mustTrigger = true;85 if(block2 != null && player == null && block2.type == Enum.Block.Type.SPAWN)86 block2.mustTrigger = true;87 88 if(player != null)89 {90 var killingBlock = (block1 != null ? block1 : block2);91 92 if(killingBlock != null && !killingBlock.landed && (!killingBlock.owner || killingBlock.owner.id != player.id))93 {94 if(killingBlock.owner == null)95 {96 this.currentGame.overlord.kill(player, killingBlock.type);97 }98 else99 {100 //Mark the player to be inserted in the next update in the killer blocks list.101 killingBlock.owner.kill(player, killingBlock.type);102 }103 }104 105 block1 = null;106 block2 = null;107 }108 //Check if blocks land.109 if(block1 != null && !block1.isStatic && (block1.launchLandTimer <= 0 || !block2))110 {111 //State can't be changed during callback.112 block1.toggleState = true;113 block1.isStatic = true;114 block1.justLanded = true;115 block1.landingTimer = Constants.Block.LANDING_TIMER;116 }117 118 if(block2 != null && !block2.isStatic && (block2.launchLandTimer <= 0 || !block1))119 {120 block2.toggleState = true;121 block2.isStatic = true;122 block2.justLanded = true;123 block2.landingTimer = Constants.Block.LANDING_TIMER;124 }125};126 127BlockListener.prototype.resolve = function(skillBlock, otherUserdata){128 129 switch(skillBlock.skill.trigger){130 case Enum.Block.Skill.Trigger.ON_LANDING:131 132 if(otherUserdata != null && otherUserdata.type == Enum.UserData.Type.PLAYER)133 return;134 135 skillBlock.mustTrigger = true;136 137 break;138 }139};140 141BlockListener.prototype.destroyLeaves = function(blockId, previousId){142 143 var block = this.currentGame.blocks[blockId];144 145 if(block != null)146 {147 block.markToDestroy(Enum.Block.Destruction.COLOR_CONTACT);148 149 if(block.linkedBlockId != null && block.linkedBlockId != previousId)150 this.destroyLeaves(block.linkedBlockId, blockId);151 }...

Full Screen

Full Screen

1.1block1.js

Source:1.1block1.js Github

copy

Full Screen

1function forBlock1(){2 if($('#block1').length > 0){3// font size4 if ($('#block1').width() > 300 && $('#block1').width() <= 400 ){5 $("#block1 .normal_font").css({6 fontSize: $('#block1').width()/200 + "px", 7 }); 8 $("#block1 .large_font").css({9 fontSize: $('#block1').width()/20 + "px", 10 }); 11 $("#block1 .very_large_font").css({12 fontSize: $('#block1').width()/20 + "px", 13 }); 14 }; 15 16 if ($('#block1').width() > 400 && $('#block1').width() <= 500 ){17 $("#block1 .normal_font").css({18 fontSize: $('#block1').width()/200 + "px", 19 }); 20 $("#block1 .large_font").css({21 fontSize: $('#block1').width()/20 + "px", 22 }); 23 $("#block1 .very_large_font").css({24 fontSize: $('#block1').width()/20 + "px", 25 }); 26 }; 27 28 if ($('#block1').width() > 500 && $('#block1').width() <= 600 ){29 $("#block1 .normal_font").css({30 fontSize: $('#block1').width()/200 + "px", 31 }); 32 $("#block1 .large_font").css({33 fontSize: $('#block1').width()/25 + "px", 34 }); 35 $("#block1 .very_large_font").css({36 fontSize: $('#block1').width()/20 + "px", 37 }); 38 }; 39 40 if ($('#block1').width() > 600 && $('#block1').width() <= 700 ){41 $("#block1 .normal_font").css({42 fontSize: $('#block1').width()/200 + "px", 43 }); 44 $("#block1 .large_font").css({45 fontSize: $('#block1').width()/39 + "px", 46 }); 47 $("#block1 .very_large_font").css({48 fontSize: $('#block1').width()/20 + "px", 49 }); 50 };51 52 if ($('#block1').width() > 700 && $('#block1').width() <= 768 ){53 $("#block1 .normal_font").css({54 fontSize: $('#block1').width()/200 + "px", 55 }); 56 $("#block1 .large_font").css({57 fontSize: $('#block1').width()/39 + "px", 58 }); 59 $("#block1 .very_large_font").css({60 fontSize: $('#block1').width()/20 + "px", 61 }); 62 };63 64 if ( $('#block1').width() > 768 && $('#block1').width() <= 992 ){65 $("#block1 .normal_font").css({66 fontSize: $('#block1').width()/200 + "px", 67 }); 68 $("#block1 .large_font").css({69 fontSize: $('#block1').width()/39 + "px", 70 }); 71 $("#block1 .very_large_font").css({72 fontSize: $('#block1').width()/20 + "px", 73 }); 74 }; 75 if ( $('#block1').width() > 992 ){76 $("#block1 .normal_font").css({77 fontSize: $('#block1').width()/200 + "px", 78 }); 79 $("#block1 .large_font").css({80 fontSize: $('#block1').width()/40 + "px", 81 }); 82 $("#block1 .very_large_font").css({83 fontSize: $('#block1').width()/25 + "px", 84 }); 85 }; 86 87 88// не соединять!!89 $("#block1 .line1 .logo_block img").css({90 width: $("#block1 .img_box").width()/100*55 + "px",91 });92 $("#block1 .line1 .logo_block img").css({93 marginTop: $("#block1 .line1 .img_box").height()/2 - $("#block1 .logo_block img").height()/2 + "px",94 marginLeft: $("#block1 .line1 .img_box").width()/2 - $("#block1 .logo_block img").width()/2 + "px",95 });96// не соединять!!97 98 99 100 101 102 103 104 105 106 107 $("#block1 .line2 .chose p").css({108 marginTop: $("#block1 .line2 .chose").height()/2 - $("#block1 .line2 .chose p").height()/2 + "px",109 });110 111 112 $("#block1 .line3 .development p").css({113 marginTop: $("#block1 .line3 .development").height()/2 - $("#block1 .line3 .development p").height()/2 + "px",114 });115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 } ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { block1 } from 'ng-mocks';2import { block2 } from 'ng-mocks';3import { block3 } from 'ng-mocks';4import { block4 } from 'ng-mocks';5import { block5 } from 'ng-mocks';6import { block6 } from 'ng-mocks';7import { block7 } from 'ng-mocks';8import { block8 } from 'ng-mocks';9import { block9 } from 'ng-mocks';10import { block10 } from 'ng-mocks';11import { block11 } from 'ng-mocks';12import { block12 } from 'ng-mocks';13import { block13 } from 'ng-mocks';14import { block14 } from 'ng-mocks';15import { block15 } from 'ng-mocks';16import { block16 } from 'ng-mocks';17import { block17 } from 'ng-mocks';18import { block18 } from 'ng-mocks';19import { block19 } from 'ng-mocks';20import { block20 } from 'ng-mocks';21import { block21 } from 'ng-mocks';22import { block22 } from 'ng-mocks';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { block1 } from 'ng-mocks';2import { MyComponent } from './my.component';3describe('MyComponent', () => {4 it('should create', () => {5 const fixture = block1(MyComponent);6 expect(fixture).toBeDefined();7 });8});9import { Component } from '@angular/core';10@Component({11})12export class MyComponent {}13import { ComponentFixture, TestBed } from '@angular/core/testing';14import { MyComponent } from './my.component';15describe('MyComponent', () => {16 let component: MyComponent;17 let fixture: ComponentFixture<MyComponent>;18 beforeEach(async () => {19 await TestBed.configureTestingModule({20 }).compileComponents();21 });22 beforeEach(() => {23 fixture = TestBed.createComponent(MyComponent);24 component = fixture.componentInstance;25 fixture.detectChanges();26 });27 it('should create', () => {28 expect(component).toBeDefined();29 });30});31import { ComponentFixture, TestBed } from '@angular/core/testing';32import { MyComponent } from './my.component';33describe('MyComponent', () => {34 let component: MyComponent;35 let fixture: ComponentFixture<MyComponent>;36 beforeEach(async () => {37 await TestBed.configureTestingModule({38 }).compileComponents();39 });40 beforeEach(() => {41 fixture = TestBed.createComponent(MyComponent);42 component = fixture.componentInstance;43 fixture.detectChanges();44 });45 it('should create', () => {46 expect(component).toBeDefined();47 });48});49import { block1 } from 'ng-mocks';50import { MyComponent } from './my.component';51describe('MyComponent', () => {52 it('should create', () => {53 const fixture = block1(MyComponent);54 expect(fixture).toBeDefined();55 });56});57import { Component } from '@angular/core';58@Component({59})60export class MyComponent {}61import { ComponentFixture, TestBed } from '@angular/core/testing';62import { MyComponent } from './my.component';63describe('MyComponent', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { block1 } from 'ng-mocks';2import { TestComponent } from './test.component';3describe('TestComponent', () => {4 it('should create', () => {5 const fixture = block1(TestComponent);6 fixture.detectChanges();7 expect(fixture).toBeTruthy();8 });9});10import { block2 } from 'ng-mocks';11import { TestComponent } from './test.component';12describe('TestComponent', () => {13 it('should create', () => {14 const fixture = block2(TestComponent);15 fixture.detectChanges();16 expect(fixture).toBeTruthy();17 });18});19import { block3 } from 'ng-mocks';20import { TestComponent } from './test.component';21describe('TestComponent', () => {22 it('should create', () => {23 const fixture = block3(TestComponent);24 fixture.detectChanges();25 expect(fixture).toBeTruthy();26 });27});28import { block4 } from 'ng-mocks';29import { TestComponent } from './test.component';30describe('TestComponent', () => {31 it('should create', () => {32 const fixture = block4(TestComponent);33 fixture.detectChanges();34 expect(fixture).toBeTruthy();35 });36});37import { block5 } from 'ng-mocks';38import { TestComponent } from './test.component';39describe('TestComponent', () => {40 it('should create', () => {41 const fixture = block5(TestComponent);42 fixture.detectChanges();43 expect(fixture).toBeTruthy();44 });45});46import { block6 } from 'ng-mocks';47import { TestComponent } from './test.component';48describe('TestComponent', () => {49 it('should create', () => {50 const fixture = block6(TestComponent);51 fixture.detectChanges();52 expect(fixture).toBeTruthy();53 });54});55import { block7 } from 'ng-mocks';56import { TestComponent } from './test.component';57describe('TestComponent', () => {58 it('should create', () => {59 const fixture = block7(TestComponent);60 fixture.detectChanges();61 expect(fixture).toBeTruthy();62 });63});

Full Screen

Using AI Code Generation

copy

Full Screen

1const block1 = require('ng-mocks/dist/block1');2const { MockBuilder, MockRender } = require('ng-mocks');3const block2 = require('ng-mocks/dist/block2');4const { MockBuilder, MockRender } = require('ng-mocks');5const block3 = require('ng-mocks/dist/block3');6const { MockBuilder, MockRender } = require('ng-mocks');7const block4 = require('ng-mocks/dist/block4');8const { MockBuilder, MockRender } = require('ng-mocks');9const block5 = require('ng-mocks/dist/block5');10const { MockBuilder, MockRender } = require('ng-mocks');11const block6 = require('ng-mocks/dist/block6');12const { MockBuilder, MockRender } = require('ng-mocks');13const block7 = require('ng-mocks/dist/block7');14const { MockBuilder, MockRender } = require('ng-mocks');15const block8 = require('ng-mocks/dist/block8');16const { MockBuilder, MockRender } = require('ng-mocks');17const block9 = require('ng-mocks/dist/block9');18const { MockBuilder, MockRender } = require('ng-mocks');19const block10 = require('ng-mocks/dist/block10');20const { MockBuilder, MockRender } = require('ng-mocks');21const block11 = require('ng-mocks/dist/block11');22const { MockBuilder, MockRender } = require('ng-mocks');23const block12 = require('ng-mocks/dist/block12');24const { MockBuilder, MockRender } = require('ng-mocks');25const block13 = require('ng-mocks/dist/block13');26const { MockBuilder, Mock

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful