bs_preroll_timer --; jQuery('#big-screen-truex-header-text').html('

PLAY BIG SCREEN AFTER THIS AD: ' + bs_preroll_timer + '

'); // document.getElementById("preroll_timer_id").innerHTML = seconds_left; if (bs_preroll_timer <= 0) { jQuery('#big-screen-truex-header-text').html('

PLAY BIG SCREEN NOW ▶

'); document.getElementById("truex-bigscreen-activate-id").onclick = function () { event.preventDefault(); $('a.requestfullscreen>span.big-screen-popover-span').html('Play Big Screen'); if (typeof bigScreenActive === 'undefined' || typeof bigScreenActive !== 'undefined' && !bigScreenActive) { jQuery('#big-screen-signup-container-id').html(""); jQuery('#big-screen-truex-overlay').remove(); start_full_screen_without_ad = false; cmg_start_game_full_screen('truex'); } } clearInterval(bs_preroll_intervalId); } }, 1000); } } // TRUEX end function cmg_start_game_full_screen(cmgsource) { myStopFunction(); // no ad refresh bigScreenActive = true; // console.log("Starting fullscreen"); if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { // trackEvent('BigScreen-Trial', 'Bigscreen activated', document.title); cmg_bigscreen_trackevent('enter', cmg_bsft); bigScreenTimer = setTimeout(function () { bigScreenTimerAction(); }, 60 * 1000); } else { // trackEvent('BigScreen-TrueX-Promo', 'Bigscreen activated', document.title); cmg_bigscreen_trackevent('enter', 0); } var elem = document.getElementById('block-system-main'); if (jQuery('html').hasClass('mobile-device')) { requestFullscreenModal(elem, document.title); return false; } if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.mozRequestFullScreen) { /* Firefox */ elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */ elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE/Edge */ elem.msRequestFullscreen(); } else { requestFullscreenModal(elem, document.title); return false; } adjustWidthHeightGame(); } function immersive_mode_display() { var popover_msg = immersive_popover_msg(); var immerse_prefix = ''; // do not add title var immerse_suffix = ''; var immerse_html = "Watch Ad To Play Big Screen"; //var immerse_html = 'Watch Ad To Play Big Screen'; $(".immerse-button").html(immerse_prefix + immerse_html + immerse_suffix); if (getCookie('cmg_fx') !== null) { jQuery('.node-type-game.logged-in .requestfullscreen').css('display', 'inline-block'); } // get game var elem = document.getElementById('block-system-main'); // open game in fullscreen $('.immerse-button .requestfullscreen').on('click', function (e) { e.preventDefault(); //console.log("function immerse button onclick handler" + new Date()); // If mobile view show full screen without any ads // if($("html").hasClass("mobile-device")) { // cmg_start_game_full_screen(); // } if(/\/test-game\//.test(window.location.pathname)){ //console.log("test page"); cmg_start_game_full_screen(); } if (cmg_stop_truex_promo === '' || cmg_stop_truex_promo !== 'yes') { // TODO: Return from here or not? if (start_full_screen_without_ad) { display_big_screen_truex_options_overlay(); } else { cmg_start_game_full_screen(); } } return; if (jQuery('#popover' + gameId).length) { jQuery('#popover' + gameId).remove(); immerse_hover_on = 0; } cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) : 0; // Logged in user if (getCookie('cmg_fx') !== null && getCookie('cmg_uid') !== null) { cmg_uid_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); if (cmg_uid_bsft !== null) { cmg_bsft = parseInt(cmg_uid_bsft); } else { cmg_bsft = 0; } } if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { if (cmg_bsft < 3) { // track event of type 'enter' cmg_bigscreen_trackevent('enter', cmg_bsft + 1); } if (getCookie('cmg_sx') !== null || getCookie("cmg_wl") !== null || cmg_bsft < 3) { cmg_start_game_full_screen(); } else { //console.log("BIG SCREEN You have reached a FT limit"); //Display signup form if(getCookie('cmg_sx') === null && getCookie('cmg_wl') === null && !popover_login_click) { display_cmg_overlay_signupform(); } // track event of type 'signup' // cmg_bigscreen_trackevent('signup', cmg_bsft+1); } } else { //Big Screen - TrueX Integration //TODO conditions to check or when to display the overlay if (getCookie('cmg_sx') === null && getCookie('cmg_wl') === null) { //console.log("Big screen button clicked. display the overlay with options"); display_big_screen_truex_options_overlay(); } else { if (cmg_bsft < 3) { // track event of type 'enter' cmg_bigscreen_trackevent('enter', cmg_bsft + 1); } if (getCookie('cmg_sx') !== null || getCookie('cmg_wl') !== null || cmg_bsft < 3) { cmg_start_game_full_screen(); } else { //console.log("BIG SCREEN You have reached a FT limit"); //Display signup form if(getCookie('cmg_sx') === null && getCookie('cmg_wl') === null && !popover_login_click) { //display_cmg_overlay_signupform(); } // track event of type 'signup' // cmg_bigscreen_trackevent('signup', cmg_bsft+1); } } } }); if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { $('.immerse-button .requestfullscreen').hover(function () { // hover in // console.log("Bigscreen button hover in "+new Date()); immerse_hover_in = 1; if (!immerse_hover_on) { popover_msg = immersive_popover_msg(); var popover_html = cmg_bs_popover_prefix + cmg_bs_popover_suffix1 + popover_msg + cmg_bs_popover_suffix2; $(".immerse-button .big-screen-popover-span").after(popover_html); var width = $(".immerse-button").find('.requestfullscreen').width(); var height = $(".immerse-button").find('.popover').height(); var xPos = '-' + (width/2); var yPos = '-' + (height + 5); $(".immerse-button").find('.popover').css("transform","translate3d("+ xPos +"px, "+ yPos + "px, 0)"); immerse_hover_on = 1; if (jQuery('#popover' + gameId).length) { jQuery('#popover' + gameId).hover(function () { //console.log("Popover message hover in "+ new Date()); big_screen_msg_on = 1 }, function () { //console.log("Popover message hover out "+ new Date()); big_screen_msg_on = 0; }); } } }, function () { // hover out // console.log("Bigscreen button hover out "+ new Date()); immerse_hover_in = 0; setTimeout(function () { if (immerse_hover_on && !immerse_hover_in && !big_screen_msg_on) { jQuery('#popover' + gameId).remove(); immerse_hover_on = 0; } }, 1 * 1000); }); } // close game fullscreen $('#block-system-main .close-full-screen').on('click', function (e) { e.preventDefault(); immersive_mode_exit_handler(); jQuery.fullscreen.exit(); }); $('body').keypress(function (e) { if (e.which == 27) { if ($('.immerse-button .requestfullscreen').length && typeof bigScreenActive !== 'undefined' && bigScreenActive) { immersive_mode_exit_handler(); // jQuery.fullscreen.exit(); } } }); var screen_change_events = "webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange"; // toggle full screen window class jQuery(document).on(screen_change_events, function () { if (jQuery.fullscreen.isFullScreen()) { /* elem.classList.add('full-screen-window'); var iframe = document.getElementById('html5game') ? document.getElementById('html5game') : document.getElementById('swfgame'); var iframeWidth = parseInt(iframe.width); var iframeHeight = parseInt(iframe.height); var windowWidth = parseInt(screen.width); var windowHeight = parseInt(screen.height) - 75; var xpbarPos = (windowHeight + 75 - iframeHeight) / 2 + iframeHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); if ($("body").hasClass("game-scalable")) { if (iframeHeight > windowHeight) { var ratio = iframeHeight / windowHeight; } else { var ratio = windowHeight / iframeHeight; } // Calculating game width based on window height var gameWidth = iframeWidth * ratio; // apply new width and height with iframe and xp bar iframe.style.width = gameWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } else if ($("body").hasClass("game-full-screen")) { // apply new width and height with iframe and xp bar iframe.style.width = windowWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } */ if (jQuery('html').hasClass('mobile-device')) { jQuery("#block-system-main #html5game").attr('src', jQuery('#playNowButton').attr('href')); } $("body").addClass('immersiveActive'); elem.classList.add('full-screen-window'); // add zoomed alert chkZoomValues(); // Adjusted width and height of iframe game adjustWidthHeightGame(); } else { if (jQuery('html').hasClass('mobile-device')) { jQuery("#block-system-main #html5game").removeAttr('src'); } immersive_mode_exit_handler(); $("body").removeClass('immersiveActive'); elem.classList.remove('full-screen-window'); // remove zoomed alert $('.zoomedalert').remove(); $('#html5game').removeAttr("style"); $('#swfgame').removeAttr("style"); $('.game-xp-bar-immerse-button').removeAttr("style"); } }); } function adjustWidthHeightGame() { var iframe = document.getElementById('html5game') ? document.getElementById('html5game') : document.getElementById('swfgame'); var iframeWidth = parseInt(iframe.width); var iframeHeight = parseInt(iframe.height); // var windowWidth = parseInt(screen.width); // var windowHeight = parseInt(screen.height) - 75; var windowWidth = parseInt($(window).width()); var windowHeight = parseInt($(window).height()); var xpbarPos = (windowHeight + 75 - iframeHeight) / 2 + iframeHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); if ($("body").hasClass("game-scalable")) { if (iframeHeight > windowHeight) { var ratio = iframeHeight / windowHeight; } else { var ratio = windowHeight / iframeHeight; } // Calculating game width based on window height var gameWidth = iframeWidth * ratio; // apply new width and height with iframe and xp bar iframe.style.width = gameWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } else if ($("body").hasClass("game-full-screen")) { // apply new width and height with iframe and xp bar iframe.style.width = windowWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } } function adjustWidthHeightModalGame(is_resize) { var iframe = $('#immersiveModal').find('#html5game'); var iframeWidth = parseInt(iframe.attr('width')); var iframeHeight = parseInt(iframe.attr('height')); var time_out = (is_resize === true) ? 500 : 0; // setTimeout(function(){ var wdWidth = parseInt($(window).width()); var wdHeight = parseInt($(window).height()); var oTwdWidth = parseInt($(window).outerWidth()); var oTwdHeight = parseInt($(window).outerHeight()); var windowWidth = (oTwdWidth > wdWidth) ? oTwdWidth : wdWidth; var windowHeight = (oTwdHeight > wdHeight) ? oTwdHeight : wdHeight; if ($("body").hasClass("game-scalable")) { if (iframeHeight > windowHeight) { var ratio = iframeHeight / windowHeight; } else { var ratio = windowHeight / iframeHeight; } // Calculating game width based on window height var gameWidth = iframeWidth * ratio; // apply new width and height with iframe iframe.css("width", windowWidth); iframe.css("height", windowHeight); } else if ($("body").hasClass("game-full-screen")) { iframe.css("width", windowWidth); iframe.css("height", windowHeight); } // }, time_out); } // adjust game width/height if screen rotate from portrait to landscape window.addEventListener("resize", function () { if ($("body").hasClass("immersiveActive")) { adjustWidthHeightGame(); } if ($("body").hasClass("isFullScreen")) { adjustWidthHeightGame(); } if ($("body").find("#immersiveModal").length) { adjustWidthHeightModalGame(true); } }, false); var cmg_mmg_html = ''; var cmg_mmg_swf_html = ''; var cmg_game_modal_attached = false; function attachModalHtml(elem, title) { cmg_game_modal_attached = true; var elem = document.getElementById('block-system-main'); html = ''; $('body').append(html); var gamewrapper = jQuery("#swfgamewrapper"); jQuery('#immersiveModal .modal-body').html(gamewrapper); if(cmg_is_mobile_device() || (jQuery(".game-page-mobile .playNow").length && jQuery(".game-page-mobile .playNow").is(':visible') ) ) { sandbox = jQuery("#html5game").attr("sandbox"); if (sandbox !== undefined) { sandbox = ' sandbox=\"' + sandbox + '\"'; } else { sandbox = ''; } newiframe = ''; if(jQuery("#html5game").length) { cmg_mmg_html = ''; } newswfiframe = ''; if(jQuery("#swfgame").length) { cmg_mmg_swf_html = ''; } if (cmg_flash_emulated_game()) { if(drupalSettings.cmatgame.flash_emulation === "1"){ //ruffle game_type = "html5"; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; var swf_game_url = 'https://www.coolmath-games.com/sites/cmatgame/files/ruffle1/ruffle.html?f='+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; cmg_mmg_swf_html = ''; } else if(drupalSettings.cmatgame.flash_emulation === "2"){ //ruffle //console.log("Cheerpx load 3"); game_type = "html5"; game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; game_type = "html5"; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); //swf_1_game_url = "/sites/default/files/games/" + swfURLArray[swfURLArray.length-1]; swf_1_game_movie_param = swfURLArray[swfURLArray.length-1]; //cheerpx js var swf_game_url = cmgGetCheerpxUrl()+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; newswfiframe = ''; jQuery("#swfgame").replaceWith(newswfiframe); //console.log("Cheerpx replace iframe 2"); } } } } function requestFullscreenModal(elem, title) { $("#immersiveModal").addClass('modal fade show full-screen-modal').css({"display":"block", "z-index":10000000}); $('body').addClass('isModalPlay'); $('#immersiveModal').find('#swfgamewrapper').show(); if($('#html5game').length || cmg_mmg_html) { jQuery("#swfgamewrapper").html(cmg_mmg_html); if (cmg_flash_emulated_game()) { jQuery("#swfgamewrapper").html(cmg_mmg_swf_html); } } else if(jQuery('#swfgame').length) { if (cmg_flash_emulated_game()) { jQuery("#swfgamewrapper").html(cmg_mmg_swf_html); } } $('#immersiveModal').find('.close').click(function () { $("#immersiveModal").remove(); }); window.location.hash = "immersiveModal"; $(window).on('hashchange', function (event) { if (window.location.hash != "#immersiveModal") { $("#immersiveModal").hide(); if($('#html5game').length) { $('#html5game').remove(); } else if(jQuery('#swfgame').length) { jQuery('#swfgame').remove(); } $('body').removeClass('isModalPlay'); } }); adjustWidthHeightModalGame(false); if (typeof browser !== "undefined" && browser == "Microsoft Internet Explorer") { if ("function" === typeof checkVersionBrowser) { ieVersion = checkVersionBrowser(); if(ieVersion == "IE 11" && !jQuery('#html5game').length) { jQuery("#swfgamewrapper").html(cmg_mmg_html); //console.log("requestFullscreenModal immersiveModal ieVersion ? "+ieVersion.length); } } } }
4.7
3,132,257 Votes
Run 3 Game

Coolmath Top Picks

Checkmate! Play the classic game of strategy. You can challenge the computer, a friend, or join a match against another online player.

Play Chess against the computer or your friends!

On the all-new Fairy Tale island, everyone's happy endings have gone awry. Can you save the day?

Save the day on the all-new Fairy Tale Island.

Swing through the jungle from tree to tree! Beat levels to unlock new monkey skins.

Monkey swing, monkey do!

Level up and earn XP on your way to the world championship. Challenge other players online in this epic penalty shootout!

Win trophies in online multiplayer!

Outlast your opponents in the ultimate copter arena. Grab upgrades and superpowers, avoid the toxic fog, and be the last one flying!

Upgrade your copter and be the last one flying!

Test your aim in online multiplayer! Race your opponent to get to zero first. You'll have to calculate your own score.

Test your aim in online multiplayer!

Play the classic game, or mix it up with an all-new action mode: fireballs, blasters, gravity wells, and more!

Play the classic game or the all-new action mode!

Your pineapple is trapped at the top of a huge tower! Jump over pits of lava and dodge dangerous traps to rescue it.

Save your pineapple from evil Big Square!

Grow your civilization during the Bronze Age. Collect food, research technology, defend yourself from other civilizations, and build a world wonder!

Grow your civilization.

Let's get rolling! It may not look like much at first, but we have a feeling you'll be earning trillions of points in no time.

Let's get rolling!

Fill the board with bricks! How many points can you score before you get stuck?

Fill the rows and columns with colorful bricks!

Step up and spin the wheel in this cool way to learn about probability! Guess higher or lower to win big points. Will you play it safe or risk it all?

Step up and spin the wheel!

Looks like a nice day to go fishing! Cast your line and reel in a legendary fish. Earn cash to buy new hooks and skills.

Cast your line and reel in a legendary fish!

The pig is on the loose! Help prevent him from escaping by placing stone walls to block his path.

The Pig is on the loose! Can you catch him?

Connect all pipes of the same color. The pipes can't cross, and you have to fill all of the space with pipes!

Connect pipes of the same color.