Jump to content

Search the Community

Showing results for tags 'tehnologie'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Gamelife - Linkuri Sociale
    • Facebook Page
    • Instagram Page
    • Steam Group
    • Gametracker Clan
  • Gamelife - Development
    • Community
    • Staff Only
    • Server Management
    • Competitions / Free games
  • Gamelife - Public Servers
    • Servers Counter-Strike:Global Offensive
    • Servers Counter-Strike 1.6
    • TeamSpeak 3
    • Discord
  • Design
    • Design
  • Gamelife - World of blogging
    • Descopera
    • Cinema
    • Lifestyle & Entertainment Hub
    • Music Lounge
  • Gamelife - IT Area
    • General Zone
    • Operating Systems
    • Python
    • Programming Languages
    • Index gaming
    • Help
  • Gamelife - General Zone
    • Projects / keys steam free / other games
    • Other Games
  • GAMELIFE - COMMUNITY's Bun venit in Clubul Gamelife
  • GAMELIFE - COMMUNITY's Discutii Libere
  • Valorant Team GL's Prezentare!
  • RESPAWN's Topics

Categories

  • Counter Strike 1.6
    • Addons
    • Plugins
    • Maps
    • Others
  • Counter Strike Global Offensive
    • Maps
    • Plugins
    • Others
  • Skins , cfg , GUIs
  • Productia Gamelife
  • Design

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Instagram


Steam Profile ID


Gender


Location


Interests


About Me

  1. //se citesc datele intr un vector . Sa se tipareasca sortat vectorul... #include <iostream> using namespace std; void citesc(int vt[10], int n) { int i; for(i=1; i<=n; i++) {cout<<"v["<<i<<"]= "; cin>>vt[i];} } void sortez(int vt[10], int n) { int i,gasit,aux; do { gasit=0; for(i=1; i<=n-1; i++) if (vt[i]>vt[i+1]) { aux=vt[i];vt[i]=vt[i+1];vt[i+1]=aux; gasit=1; } }while(gasit); // {cout<<"v["<<i<<"]= "; cin>>vt[i];} } void scriu(int vt[10], int n) { int i; for(i=1; i<=n; i++) cout<<vt[i]<<endl; } int main(void) { int n, v[30]; cout<<"Dati dimensiunile vectorului \n"; cout<<"n = ";cin>>n; citesc (v,n); sortez(v,n); scriu(v,n); }
  2. Username:cReTzUUUU Creator (sau editor):cReTzUUUU Poze/Video în care prezinți index-ul: Versiune dextop: Versiune pentru mobil: Link Virustotal:https://www.virustotal.com/gui/file/f08aa2fee5900f452562db01fd2a17d78f5c4de1ee29f32cdf70fb2fea45f357/detection Link download : https://www66.zippyshare.com/v/YEIkj31G/file.html Alte precizări: 1.Index-ul conține elemente de css, html, javascrip, jquery, bootstrap. 2.Index-ul este optimizat SEO , mobile SEO consta in optimizarea unui site si pentru celelalte device-uri, respectiv smartphone si tableta. Optimizarea SEO a site-ului pentru mobil inseamna de asemenea ca resursele site-ului tau vor fi accesibile motoarelor de cautare.
  3. Username: Creator (sau editor): knights Poze/Video în care prezinți index-ul: https://bootstrapmade.com/demo/Knight/ Link Virustotal: - Link download (cu hide): https://bootstrapmade.com/demo/Knight/ Alte precizări: se downloadeaza direct de pe site !
  4. Script: <script type="text/javascript"> today = new Date(); BigDay= new Date("December 25, 2020"); msPerDay = 24 * 60 * 60 * 1000; timeLeft = (BigDay.getTime() - today.getTime()); e_daysLeft = timeLeft / msPerDay; daysLeft = Math.floor(e_daysLeft); e_hrsLeft = (e_daysLeft - daysLeft)*24; hrsLeft = Math.floor(e_hrsLeft); minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60); document.write("There are only <BR> <H4>" + daysLeft + " days " + hrsLeft + " hours and " + minsLeft + " minutes left </H4> Until Christmas<P>"); </script>
  5. #include<iostream.h> long long ack(long m, long n) { if (!m) return n+1; else if (!n) return ack(m-1,1); else return ack(m-1, ack(m,n-1)); } int main() { long long m,n; cout<<"Introduceti prima cifra: "; cin>>m; cout<<"Introduceti al doilea numar: "; cin>>n; cout<<ack(m,n); return 0; }
  6. Sa se calculeze aria si perimetrul unui pătrat prin introducerea lungimii laturii de la tastatură. Sa se afișeze rezultatul perimetrului și al ariei. #include <iostream> using namespace std; int main() { int l,p,A; cout<<"l="; cin>>l; p=4*l; cout<<"p="<<p; A=l*l; cout<<"\nA="<<A; }
  7. Script: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <style> .fa { font-size: 50px; cursor: pointer; user-select: none; } .fa:hover { color: darkblue; } </style> </head> <body> <p>Click on the icon to toggle between thumbs-up and thumbs-down (like/dislike):</p> <i onclick="myFunction(this)" class="fa fa-thumbs-up"></i> <script> function myFunction(x) { x.classList.toggle("fa-thumbs-down"); } </script> </body> </html>
  8. Script: <!DOCTYPE html> <html> <style> #text {display:none;color:red} </style> <body> <h3>Detect Caps Lock</h3> <p>Press the "Caps Lock" key inside the input field to trigger the function.</p> <input id="myInput" value="Some text.."> <p id="text">WARNING! Caps lock is ON.</p> <script> var input = document.getElementById("myInput"); var text = document.getElementById("text"); input.addEventListener("keyup", function(event) { if (event.getModifierState("CapsLock")) { text.style.display = "block"; } else { text.style.display = "none" } }); </script> </body> </html>
  9. Script: 1.Html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Neon Light Button Hover</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" media="screen" href="style.css" /> <script src="main.js"></script> </head> <body> <a href="#"> <span></span> <span></span> <span></span> <span></span> Neon Button </a> </body> </html> 2.CSS body{ margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #031321; font-family: consolas; } a{ position: relative; display: inline-block; padding: 15px 30px; color: #2196f3; text-transform: uppercase; letter-spacing: 4px; text-decoration: none; font-size: 24px; overflow: hidden; transition: 0.2s; } a:hover{ color: #255784; background: #2196f3; box-shadow: 0 0 10px #2196f3,0 0 40px #2196f3,0 0 80px #2196f3; transition-delay: 1s; } a span{ position: absolute; display: block; } a span:nth-child(1){ top: 0; left: -100%; width: 100%; height: 2px; background: linear-gradient(90deg,transparent,#2196f3); } a:hover span:nth-child(1){ left: 100%; transition: 1s; } a span:nth-child(3){ bottom: 0; right: -100%; width: 100%; height: 2px; background: linear-gradient(270deg,transparent,#2196f3); } a:hover span:nth-child(3){ right: 100%; transition: 1s; transition-delay: 0.5s; } a span:nth-child(2){ top: -100%; right: 0; width: 2px; height: 100%; background: linear-gradient(180deg,transparent,#2196f3); } a:hover span:nth-child(2){ top: 100%; transition: 1s; transition-delay: 0.25s; } a span:nth-child(4){ bottom: -100%; left: 0; width: 2px; height: 100%; background: linear-gradient(360deg,transparent,#2196f3); } a:hover span:nth-child(4){ bottom: 100%; transition: 1s; transition-delay: 0.75s; }
  10. Creați un buton care va duce utilizatorul în partea de sus a paginii atunci când faceți clic pe el."Scroll Back To Top Button" Pasul 1. Add HTML: Exemplu: <button onclick="topFunction()" id="myBtn" title="Go to top">Top</button> Pasul 2: Pasul 2. Add CSS: #myBtn { display: none; /* Hidden by default */ position: fixed; /* Fixed/sticky position */ bottom: 20px; /* Place the button at the bottom of the page */ right: 30px; /* Place the button 30px from the right */ z-index: 99; /* Make sure it does not overlap */ border: none; /* Remove borders */ outline: none; /* Remove outline */ background-color: red; /* Set a background color */ color: white; /* Text color */ cursor: pointer; /* Add a mouse pointer on hover */ padding: 15px; /* Some padding */ border-radius: 10px; /* Rounded corners */ font-size: 18px; /* Increase font size */ } #myBtn:hover { background-color: #555; /* Add a dark-grey background on hover */ } Pasul 3. Add JavaScript: //Get the button: mybutton = document.getElementById("myBtn"); // When the user scrolls down 20px from the top of the document, show the button window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { mybutton.style.display = "block"; } else { mybutton.style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera }
  11. Demo: Script: <!DOCTYPE html> <html> <body> <p>Click on the "Choose File" button to upload a file:</p> <form action="/action_page.php"> <input type="file" id="myFile" name="filename"> <input type="submit"> </form> </body> </html>
  12. Script: <!DOCTYPE html> <html> <body> <p>Click the radio button to toggle between password visibility:</p> Password: <input type="password" value="FakePSW" id="myInput"><br><br> <input type="checkbox" onclick="myFunction()">Show Password <script> function myFunction() { var x = document.getElementById("myInput"); if (x.type === "password") { x.type = "text"; } else { x.type = "password"; } } </script> </body> </html>
  13. #include <iostream> using namespace std; int main() { int n,i,j,a[10][10],b[10][10],c[10][10]; cout<<"Introduceti gradul matricei:"; cin>>n; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ cout<<"A["<<i<<"]["<<j<<"]="; cin>>a[i][j]; }} for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ cout<<"B["<<i<<"]["<<j<<"]="; cin>>b[i][j]; }} for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ c[i][j]=a[i][j]+b[i][j]; }} for(i=1;i<=n;i++){ for(j=1;j<=n;j++) cout<<c[i][j]<<" "; cout<<endl; } return 0; }
  14. <!DOCTYPE html> <html> <head> <title></title> <style> html, body { height: 100%; margin: 0; } body { background: black; display: flex; align-items: center; justify-content: center; } canvas { border: 1px solid white; } </style> </head> <body> <canvas width="320" height="640" id="game"></canvas> <script> // https://tetris.fandom.com/wiki/Tetris_Guideline // get a random integer between the range of [min,max] // @see https://stackoverflow.com/a/1527820/2124254 function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } // generate a new tetromino sequence // @see https://tetris.fandom.com/wiki/Random_Generator function generateSequence() { const sequence = ['I', 'J', 'L', 'O', 'S', 'T', 'Z']; while (sequence.length) { const rand = getRandomInt(0, sequence.length - 1); const name = sequence.splice(rand, 1)[0]; tetrominoSequence.push(name); } } // get the next tetromino in the sequence function getNextTetromino() { if (tetrominoSequence.length === 0) { generateSequence(); } const name = tetrominoSequence.pop(); const matrix = tetrominos[name]; // I and O start centered, all others start in left-middle const col = playfield[0].length / 2 - Math.ceil(matrix[0].length / 2); // I starts on row 21 (-1), all others start on row 22 (-2) const row = name === 'I' ? -1 : -2; return { name: name, // name of the piece (L, O, etc.) matrix: matrix, // the current rotation matrix row: row, // current row (starts offscreen) col: col // current col }; } // rotate an NxN matrix 90deg // @see https://codereview.stackexchange.com/a/186834 function rotate(matrix) { const N = matrix.length - 1; const result = matrix.map((row, i) => row.map((val, j) => matrix[N - j][i]) ); return result; } // check to see if the new matrix/row/col is valid function isValidMove(matrix, cellRow, cellCol) { for (let row = 0; row < matrix.length; row++) { for (let col = 0; col < matrix[row].length; col++) { if (matrix[row][col] && ( // outside the game bounds cellCol + col < 0 || cellCol + col >= playfield[0].length || cellRow + row >= playfield.length || // collides with another piece playfield[cellRow + row][cellCol + col]) ) { return false; } } } return true; } // place the tetromino on the playfield function placeTetromino() { for (let row = 0; row < tetromino.matrix.length; row++) { for (let col = 0; col < tetromino.matrix[row].length; col++) { if (tetromino.matrix[row][col]) { // game over if piece has any part offscreen if (tetromino.row + row < 0) { return showGameOver(); } playfield[tetromino.row + row][tetromino.col + col] = tetromino.name; } } } // check for line clears starting from the bottom and working our way up for (let row = playfield.length - 1; row >= 0; ) { if (playfield[row].every(cell => !!cell)) { // drop every row above this one for (let r = row; r >= 0; r--) { for (let c = 0; c < playfield[r].length; c++) { playfield[r][c] = playfield[r-1][c]; } } } else { row--; } } tetromino = getNextTetromino(); } // show the game over screen function showGameOver() { cancelAnimationFrame(rAF); gameOver = true; context.fillStyle = 'black'; context.globalAlpha = 0.75; context.fillRect(0, canvas.height / 2 - 30, canvas.width, 60); context.globalAlpha = 1; context.fillStyle = 'white'; context.font = '36px monospace'; context.textAlign = 'center'; context.textBaseline = 'middle'; context.fillText('GAME OVER!', canvas.width / 2, canvas.height / 2); } const canvas = document.getElementById('game'); const context = canvas.getContext('2d'); const grid = 32; const tetrominoSequence = []; // keep track of what is in every cell of the game using a 2d array // tetris playfield is 10x20, with a few rows offscreen const playfield = []; // populate the empty state for (let row = -2; row < 20; row++) { playfield[row] = []; for (let col = 0; col < 10; col++) { playfield[row][col] = 0; } } // how to draw each tetromino // @see https://tetris.fandom.com/wiki/SRS const tetrominos = { 'I': [ [0,0,0,0], [1,1,1,1], [0,0,0,0], [0,0,0,0] ], 'J': [ [1,0,0], [1,1,1], [0,0,0], ], 'L': [ [0,0,1], [1,1,1], [0,0,0], ], 'O': [ [1,1], [1,1], ], 'S': [ [0,1,1], [1,1,0], [0,0,0], ], 'Z': [ [1,1,0], [0,1,1], [0,0,0], ], 'T': [ [0,1,0], [1,1,1], [0,0,0], ] }; // color of each tetromino const colors = { 'I': 'cyan', 'O': 'yellow', 'T': 'purple', 'S': 'green', 'Z': 'red', 'J': 'blue', 'L': 'orange' }; let count = 0; let tetromino = getNextTetromino(); let rAF = null; // keep track of the animation frame so we can cancel it let gameOver = false; // game loop function loop() { rAF = requestAnimationFrame(loop); context.clearRect(0,0,canvas.width,canvas.height); // draw the playfield for (let row = 0; row < 20; row++) { for (let col = 0; col < 10; col++) { if (playfield[row][col]) { const name = playfield[row][col]; context.fillStyle = colors[name]; // drawing 1 px smaller than the grid creates a grid effect context.fillRect(col * grid, row * grid, grid-1, grid-1); } } } // draw the active tetromino if (tetromino) { // tetromino falls every 35 frames if (++count > 35) { tetromino.row++; count = 0; // place piece if it runs into anything if (!isValidMove(tetromino.matrix, tetromino.row, tetromino.col)) { tetromino.row--; placeTetromino(); } } context.fillStyle = colors[tetromino.name]; for (let row = 0; row < tetromino.matrix.length; row++) { for (let col = 0; col < tetromino.matrix[row].length; col++) { if (tetromino.matrix[row][col]) { // drawing 1 px smaller than the grid creates a grid effect context.fillRect((tetromino.col + col) * grid, (tetromino.row + row) * grid, grid-1, grid-1); } } } } } // listen to keyboard events to move the active tetromino document.addEventListener('keydown', function(e) { if (gameOver) return; // left and right arrow keys (move) if (e.which === 37 || e.which === 39) { const col = e.which === 37 ? tetromino.col - 1 : tetromino.col + 1; if (isValidMove(tetromino.matrix, tetromino.row, col)) { tetromino.col = col; } } // up arrow key (rotate) if (e.which === 38) { const matrix = rotate(tetromino.matrix); if (isValidMove(matrix, tetromino.row, tetromino.col)) { tetromino.matrix = matrix; } } // down arrow key (drop) if(e.which === 40) { const row = tetromino.row + 1; if (!isValidMove(tetromino.matrix, row, tetromino.col)) { tetromino.row = row - 1; placeTetromino(); return; } tetromino.row = row; } }); // start the game rAF = requestAnimationFrame(loop); </script> </body> </html>
  15. Bomberman <!DOCTYPE html> <html> <head> <title></title> <style> html, body { height: 100%; margin: 0; } body { background: black; display: flex; align-items: center; justify-content: center; } canvas { background: forestgreen; } </style> </head> <body> <canvas width="960" height="832" id="game"></canvas> <script> const canvas = document.getElementById('game'); const context = canvas.getContext('2d'); const grid = 64; const numRows = 13; const numCols = 15; // create a new canvas and draw the soft wall image. then we can use this // canvas to draw the images later on const softWallCanvas = document.createElement('canvas'); const softWallCtx = softWallCanvas.getContext('2d'); softWallCanvas.width = softWallCanvas.height = grid; softWallCtx.fillStyle = 'black'; softWallCtx.fillRect(0, 0, grid, grid); softWallCtx.fillStyle = '#a9a9a9'; // 1st row brick softWallCtx.fillRect(1, 1, grid - 2, 20); // 2nd row bricks softWallCtx.fillRect(0, 23, 20, 18); softWallCtx.fillRect(22, 23, 42, 18); // 3rd row bricks softWallCtx.fillRect(0, 43, 42, 20); softWallCtx.fillRect(44, 43, 20, 20); // create a new canvas and draw the soft wall image. then we can use this // canvas to draw the images later on const wallCanvas = document.createElement('canvas'); const wallCtx = wallCanvas.getContext('2d'); wallCanvas.width = wallCanvas.height = grid; wallCtx.fillStyle = 'black'; wallCtx.fillRect(0, 0, grid, grid); wallCtx.fillStyle = 'white'; wallCtx.fillRect(0, 0, grid - 2, grid - 2); wallCtx.fillStyle = '#a9a9a9'; wallCtx.fillRect(2, 2, grid - 4, grid - 4); // create a mapping of object types const types = { wall: '▉', softWall: 1, bomb: 2 }; // keep track of all entities let entities = []; // keep track of what is in every cell of the game using a 2d array. the // template is used to note where walls are and where soft walls cannot spawn. // '▉' represents a wall // 'x' represents a cell that cannot have a soft wall (player start zone) let cells = []; const template = [ ['▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉'], ['▉','x','x', , , , , , , , , ,'x','x','▉'], ['▉','x','▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉','x','▉'], ['▉','x', , , , , , , , , , , ,'x','▉'], ['▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉'], ['▉', , , , , , , , , , , , , ,'▉'], ['▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉'], ['▉', , , , , , , , , , , , , ,'▉'], ['▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉'], ['▉','x', , , , , , , , , , , ,'x','▉'], ['▉','x','▉', ,'▉', ,'▉', ,'▉', ,'▉', ,'▉','x','▉'], ['▉','x','x', , , , , , , , , ,'x','x','▉'], ['▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉','▉'] ]; // populate the level with walls and soft walls function generateLevel() { cells = []; for (let row = 0; row < numRows; row++) { cells[row] = []; for (let col = 0; col < numCols; col++) { // 90% chance cells will contain a soft wall if (!template[row][col] && Math.random() < 0.90) { cells[row][col] = types.softWall; } else if (template[row][col] === types.wall) { cells[row][col] = types.wall; } } } } // blow up a bomb and its surrounding tiles function blowUpBomb(bomb) { // bomb has already exploded so don't blow up again if (!bomb.alive) return; bomb.alive = false; // remove bomb from grid cells[bomb.row][bomb.col] = null; // explode bomb outward by size const dirs = [{ // up row: -1, col: 0 }, { // down row: 1, col: 0 }, { // left row: 0, col: -1 }, { // right row: 0, col: 1 }]; dirs.forEach((dir) => { for (let i = 0; i < bomb.size; i++) { const row = bomb.row + dir.row * i; const col = bomb.col + dir.col * i; const cell = cells[row][col]; // stop the explosion if it hit a wall if (cell === types.wall) { return; } // center of the explosion is the first iteration of the loop entities.push(new Explosion(row, col, dir, i === 0 ? true : false)); cells[row][col] = null; // bomb hit another bomb so blow that one up too if (cell === types.bomb) { // find the bomb that was hit by comparing positions const nextBomb = entities.find((entity) => { return ( entity.type === types.bomb && entity.row === row && entity.col === col ); }); blowUpBomb(nextBomb); } // stop the explosion if hit anything if (cell) { return; } } }); } // bomb constructor function function Bomb(row, col, size, owner) { this.row = row; this.col = col; this.radius = grid * 0.4; this.size = size; // the size of the explosion this.owner = owner; // which player placed this bomb this.alive = true; this.type = types.bomb; // bomb blows up after 3 seconds this.timer = 3000; // update the bomb each frame this.update = function(dt) { this.timer -= dt; // blow up bomb if timer is done if (this.timer <= 0) { return blowUpBomb(this); } // change the size of the bomb every half second. we can determine the size // by dividing by 500 (half a second) and taking the ceiling of the result. // then we can check if the result is even or odd and change the size const interval = Math.ceil(this.timer / 500); if (interval % 2 === 0) { this.radius = grid * 0.4; } else { this.radius = grid * 0.5; } }; // render the bomb each frame this.render = function() { const x = (this.col + 0.5) * grid; const y = (this.row + 0.5) * grid; // draw bomb context.fillStyle = 'black'; context.beginPath(); context.arc(x, y, this.radius, 0, 2 * Math.PI); context.fill(); // draw bomb fuse moving up and down with the bomb size const fuseY = (this.radius === grid * 0.5 ? grid * 0.15 : 0); context.strokeStyle = 'white'; context.lineWidth = 5; context.beginPath(); context.arc( (this.col + 0.75) * grid, (this.row + 0.25) * grid - fuseY, 10, Math.PI, -Math.PI / 2 ); context.stroke(); }; } // explosion constructor function function Explosion(row, col, dir, center) { this.row = row; this.col = col; this.dir = dir; this.alive = true; // show explosion for 0.3 seconds this.timer = 300; // update the explosion each frame this.update = function(dt) { this.timer -= dt; if (this.timer <=0) { this.alive = false; } }; // render the explosion each frame this.render = function() { const x = this.col * grid; const y = this.row * grid; const horizontal = this.dir.col; const vertical = this.dir.row; // create a fire effect by stacking red, orange, and yellow on top of // each other using progressively smaller rectangles context.fillStyle = '#D72B16'; // red context.fillRect(x, y, grid, grid); context.fillStyle = '#F39642'; // orange // determine how to draw based on if it's vertical or horizontal // center draws both ways if (center || horizontal) { context.fillRect(x, y + 6, grid, grid - 12); } if (center || vertical) { context.fillRect(x + 6, y, grid - 12, grid); } context.fillStyle = '#FFE5A8'; // yellow if (center || horizontal) { context.fillRect(x, y + 12, grid, grid - 24); } if (center || vertical) { context.fillRect(x + 12, y, grid - 24, grid); } }; } // player character (just a simple circle) const player = { row: 1, col: 1, numBombs: 1, bombSize: 3, radius: grid * 0.35, render() { const x = (this.col + 0.5) * grid; const y = (this.row + 0.5) * grid; context.save(); context.fillStyle = 'white'; context.beginPath(); context.arc(x, y, this.radius, 0, 2 * Math.PI); context.fill(); } } // game loop let last; let dt; function loop(timestamp) { requestAnimationFrame(loop); context.clearRect(0,0,canvas.width,canvas.height); // calculate the time difference since the last update. requestAnimationFrame // passes the current timestamp as a parameter to the loop if (!last) { last = timestamp; } dt = timestamp - last; last = timestamp; // update and render everything in the grid for (let row = 0; row < numRows; row++) { for (let col = 0; col < numCols; col++) { switch(cells[row][col]) { case types.wall: context.drawImage(wallCanvas, col * grid, row * grid); break; case types.softWall: context.drawImage(softWallCanvas, col * grid, row * grid); break; } } } // update and render all entities entities.forEach((entity) => { entity.update(dt); entity.render(); }); // remove dead entities entities = entities.filter((entity) => entity.alive); player.render(); } // listen to keyboard events to move the snake document.addEventListener('keydown', function(e) { let row = player.row; let col = player.col; // left arrow key if (e.which === 37) { col--; } // up arrow key else if (e.which === 38) { row--; } // right arrow key else if (e.which === 39) { col++; } // down arrow key else if (e.which === 40) { row++; } // space key (bomb) else if ( e.which === 32 && !cells[row][col] && // count the number of bombs the player has placed entities.filter((entity) => { return entity.type === types.bomb && entity.owner === player }).length < player.numBombs ) { // place bomb const bomb = new Bomb(row, col, player.bombSize, player); entities.push(bomb); cells[row][col] = types.bomb; } // don't move the player if something is already at that position if (!cells[row][col]) { player.row = row; player.col = col; } }); // start the game generateLevel(); requestAnimationFrame(loop); </script> </body> </html>
  16. /Sortarea prin interschimbare // se parcurge vectorul inversand continuturile elementelor alaturate care nu sunt crescatoare #include <iostream> using namespace std; int a[100], n, i,j ,k ,man, gasit ; int main() { cout<<"Dati dimensiunea tabloului n = "; cin>>n; for(i=0; i<n; i++) { cout<<"a["<<i<<"] = "; cin>>a[i]; } do { gasit=0; for(i=0; i<n-1; i++) if (a[i]>a[i+1]) { man=a[i]; a[i]=a[i+1]; a[i+1]=man; gasit=1; } } while (gasit); { cout<<"Tabloul ordonat crescator \n"; for(i=0; i<n; i++) cout<<a[i]<<" "; } }
  17. Code: <!DOCTYPE html> <html> <style> body {font-family: Arial, Helvetica, sans-serif;} form { border: 3px solid #f1f1f1; font-family: Arial; } .container { padding: 20px; background-color: #f1f1f1; } input[type=text], input[type=submit] { width: 100%; padding: 12px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; box-sizing: border-box; } input[type=checkbox] { margin-top: 16px; } input[type=submit] { background-color: blue; color: white; border: none; } input[type=submit]:hover { opacity: 0.8; } </style> <body> <form action="/action_page.php"> <div class="container"> <h2>Subscribe to our Newsletter</h2> </div> <div class="container" style="background-color:white"> <input type="text" placeholder="Name" name="name" required> <input type="text" placeholder="Email address" name="mail" required> <label> <input type="checkbox" checked="checked" name="subscribe"> Daily Newsletter </label> </div> <div class="container"> <input type="submit" value="Subscribe"> </div> </form> </body> </html>
  18. Snake HTML Game: Code: <!DOCTYPE html> <html> <head> <title></title> <style> html, body { height: 100%; margin: 0; } body { background: black; display: flex; align-items: center; justify-content: center; } canvas { border: 1px solid white; } </style> </head> <body> <canvas width="400" height="400" id="game"></canvas> <script> var canvas = document.getElementById('game'); var context = canvas.getContext('2d'); var grid = 16; var count = 0; var snake = { x: 160, y: 160, // snake velocity. moves one grid length every frame in either the x or y direction dx: grid, dy: 0, // keep track of all grids the snake body occupies cells: [], // length of the snake. grows when eating an apple maxCells: 4 }; var apple = { x: 320, y: 320 }; // get random whole numbers in a specific range // @see https://stackoverflow.com/a/1527820/2124254 function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } // game loop function loop() { requestAnimationFrame(loop); // slow game loop to 15 fps instead of 60 (60/15 = 4) if (++count < 4) { return; } count = 0; context.clearRect(0,0,canvas.width,canvas.height); // move snake by it's velocity snake.x += snake.dx; snake.y += snake.dy; // wrap snake position horizontally on edge of screen if (snake.x < 0) { snake.x = canvas.width - grid; } else if (snake.x >= canvas.width) { snake.x = 0; } // wrap snake position vertically on edge of screen if (snake.y < 0) { snake.y = canvas.height - grid; } else if (snake.y >= canvas.height) { snake.y = 0; } // keep track of where snake has been. front of the array is always the head snake.cells.unshift({x: snake.x, y: snake.y}); // remove cells as we move away from them if (snake.cells.length > snake.maxCells) { snake.cells.pop(); } // draw apple context.fillStyle = 'red'; context.fillRect(apple.x, apple.y, grid-1, grid-1); // draw snake one cell at a time context.fillStyle = 'green'; snake.cells.forEach(function(cell, index) { // drawing 1 px smaller than the grid creates a grid effect in the snake body so you can see how long it is context.fillRect(cell.x, cell.y, grid-1, grid-1); // snake ate apple if (cell.x === apple.x && cell.y === apple.y) { snake.maxCells++; // canvas is 400x400 which is 25x25 grids apple.x = getRandomInt(0, 25) * grid; apple.y = getRandomInt(0, 25) * grid; } // check collision with all cells after this one (modified bubble sort) for (var i = index + 1; i < snake.cells.length; i++) { // snake occupies same space as a body part. reset game if (cell.x === snake.cells[i].x && cell.y === snake.cells[i].y) { snake.x = 160; snake.y = 160; snake.cells = []; snake.maxCells = 4; snake.dx = grid; snake.dy = 0; apple.x = getRandomInt(0, 25) * grid; apple.y = getRandomInt(0, 25) * grid; } } }); } // listen to keyboard events to move the snake document.addEventListener('keydown', function(e) { // prevent snake from backtracking on itself by checking that it's // not already moving on the same axis (pressing left while moving // left won't do anything, and pressing right while moving left // shouldn't let you collide with your own body) // left arrow key if (e.which === 37 && snake.dx === 0) { snake.dx = -grid; snake.dy = 0; } // up arrow key else if (e.which === 38 && snake.dy === 0) { snake.dy = -grid; snake.dx = 0; } // right arrow key else if (e.which === 39 && snake.dx === 0) { snake.dx = grid; snake.dy = 0; } // down arrow key else if (e.which === 40 && snake.dy === 0) { snake.dy = grid; snake.dx = 0; } }); // start the game requestAnimationFrame(loop); </script> </body> </html>
  19. Gun Fight HTML Game: Script: <!DOCTYPE html> <html> <head> <title></title> <style> html, body { height: 100%; margin: 0; } body { background: black; display: flex; align-items: center; justify-content: center; } </style> </head> <body> <canvas width="565" height="500" id="game"></canvas> <script> const canvas = document.getElementById('game'); const context = canvas.getContext('2d'); const grid = 15; const playerHeight = grid * 3; // 45 const maxPlayerY = canvas.height - grid - playerHeight; var playerSpeed = 4; const leftPlayer = { // start in the middle of the game on the left side x: grid * 2, y: canvas.height / 2 - playerHeight / 2, width: grid, height: playerHeight, // shooting cooldown cooldown: 0, // player velocity dy: 0 }; const rightPlayer = { // start in the middle of the game on the right side x: canvas.width - grid * 3, y: canvas.height / 2 - playerHeight / 2, width: grid, height: playerHeight, // shooting cooldown cooldown: 0, // player velocity dy: 0 }; const bullets = { speed: 5, array: [] } // check for collision between two objects using axis-aligned bounding box (AABB) // @see https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection function collides(obj1, obj2) { return obj1.x < obj2.x + obj2.width && obj1.x + obj1.width > obj2.x && obj1.y < obj2.y + obj2.height && obj1.y + obj1.height > obj2.y; } // game loop function loop() { requestAnimationFrame(loop); context.clearRect(0,0,canvas.width,canvas.height); // bullet cooldowns // left player if (leftPlayer.cooldown > 0) { leftPlayer.cooldown--; } // right player if (rightPlayer.cooldown > 0) { rightPlayer.cooldown--; } // move players by their velocity leftPlayer.y += leftPlayer.dy; rightPlayer.y += rightPlayer.dy; // prevent players from going through walls if (leftPlayer.y < grid) { leftPlayer.y = grid; } else if (leftPlayer.y > maxPlayerY) { leftPlayer.y = maxPlayerY; } if (rightPlayer.y < grid) { rightPlayer.y = grid; } else if (rightPlayer.y > maxPlayerY) { rightPlayer.y = maxPlayerY; } // draw bullets context.fillStyle = 'yellow'; bullets.array.forEach(function(bullet, index) { context.fillRect(bullet.x, bullet.y, 10, 5); // check if the bullet hits a player // left player if (collides(bullet, leftPlayer)) { bullets.array.splice(index, 1); leftPlayer.y = canvas.height / 2 - playerHeight / 2; rightPlayer.y = canvas.height / 2 - playerHeight / 2; bullets.array.length = 0; } // right player else if (collides(bullet, rightPlayer)) { bullets.array.splice(index, 1); leftPlayer.y = canvas.height / 2 - playerHeight / 2; rightPlayer.y = canvas.height / 2 - playerHeight / 2; bullets.array.length = 0; } // move bullets bullet.x += bullet.dx; // remove bullets that leave the screen if (bullet.x < 0 || bullet.x > canvas.width) { bullets.array.splice(index, 1); } }); // draw paddles context.fillStyle = 'gold'; context.fillRect(leftPlayer.x, leftPlayer.y, leftPlayer.width, leftPlayer.height); context.fillRect(rightPlayer.x, rightPlayer.y, rightPlayer.width, rightPlayer.height); // draw walls context.fillStyle = 'lightgray'; context.fillRect(0, 0, canvas.width, grid); context.fillRect(0, canvas.height - grid, canvas.width, canvas.height); } // listen to keyboard events to move the players document.addEventListener('keydown', function(e) { // up arrow key if (e.which === 38) { rightPlayer.dy = -playerSpeed; } // down arrow key else if (e.which === 40) { rightPlayer.dy = playerSpeed; } // w key if (e.which === 87) { leftPlayer.dy = -playerSpeed; } // a key else if (e.which === 83) { leftPlayer.dy = playerSpeed; } // shooting // left arrow key if (e.which === 37 && rightPlayer.cooldown === 0) { bullets.array.push({ x: rightPlayer.x - 10, y: rightPlayer.y + 20, width: 10, height: 5, dx: -bullets.speed }); rightPlayer.cooldown = 25; } // d key if (e.which === 68 && leftPlayer.cooldown === 0) { bullets.array.push({ x: leftPlayer.x + 15, y: leftPlayer.y + 20, width: 10, height: 5, dx: bullets.speed }); leftPlayer.cooldown = 25; } }); // listen to keyboard events to stop the player if key is released document.addEventListener('keyup', function(e) { if (e.which === 38 || e.which === 40) { rightPlayer.dy = 0; } if (e.which === 83 || e.which === 87) { leftPlayer.dy = 0; } }); // start the game requestAnimationFrame(loop); </script> </body> </html> sursa:github.com
  20. PHP - MySQL Login Acest tutorial demonstrează cum se creează o pagină de conectare cu baza de date MySQL. Înainte de a intra în cod, ar fi nevoie de privilegii speciale pentru a crea sau pentru a șterge o bază de date MySQL. Config.php Fișierul Config.php are informații despre configurația bazei de date MySQL. <?php define('DB_SERVER', 'localhost:3036'); define('DB_USERNAME', 'root'); define('DB_PASSWORD', 'rootpassword'); define('DB_DATABASE', 'database'); $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE); ?> Login.php Fisierul Login.php conține informații despre scriptul php și scriptul HTML pentru a vă autentifica. ?php include("config.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form $myusername = mysqli_real_escape_string($db,$_POST['username']); $mypassword = mysqli_real_escape_string($db,$_POST['password']); $sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); $active = $row['active']; $count = mysqli_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count == 1) { session_register("myusername"); $_SESSION['login_user'] = $myusername; header("location: welcome.php"); }else { $error = "Your Login Name or Password is invalid"; } } ?> <html> <head> <title>Login Page</title> <style type = "text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:14px; } label { font-weight:bold; width:100px; font-size:14px; } .box { border:#666666 solid 1px; } </style> </head> <body bgcolor = "#FFFFFF"> <div align = "center"> <div style = "width:300px; border: solid 1px #333333; " align = "left"> <div style = "background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div> <div style = "margin:30px"> <form action = "" method = "post"> <label>UserName :</label><input type = "text" name = "username" class = "box"/><br /><br /> <label>Password :</label><input type = "password" name = "password" class = "box" /><br/><br /> <input type = "submit" value = " Submit "/><br /> </form> <div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div> </div> </div> </div> </body> </html> După conectarea reușită, va afișa pagina de bun venit. (welcome.php) <?php include('session.php'); ?> <html"> <head> <title>Welcome </title> </head> <body> <h1>Welcome <?php echo $login_session; ?></h1> <h2><a href = "logout.php">Sign Out</a></h2> </body> </html> Logoutpage.php Pagina de deconectare conține informații despre modul de deconectare din sesiune <?php session_start(); if(session_destroy()) { header("Location: login.php"); } ?> Session.php va verifica sesiunea, dacă nu există sesiune, se va redirecționa către pagina de conectare. <?php include('config.php'); session_start(); $user_check = $_SESSION['login_user']; $ses_sql = mysqli_query($db,"select username from admin where username = '$user_check' "); $row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC); $login_session = $row['username']; if(!isset($_SESSION['login_user'])){ header("location:login.php"); die(); } ?> Sursa:tutorialspoint.com
  21. //(metoda bulelor) Se parcurge vectorul atât timp cât mai există o pereche (a,a[i+1]) cu a > a[i+1] (adică o pereche de numere astfel încât primul să fie mai mare ca cel de-al doilea). #include<iostream> using namespace std; int a[100],n,i; void bubble_sort(int a[100], int n) // a - tabloul de numere intregi care se va ordona crescator // n - numarul de elemente al tabloului { int i,aux,inv; // variabila inv este 0 atunci cand s-a facut o interschimbare do{ inv=1; for(i=1; i<=n-1; i++) if( a[i] > a[i+1] ) { aux = a[i]; a[i] = a[i+1]; a[i+1] = aux; inv = 0; } }while( !inv ); return; } int main(void) { cout<<"Dati dimensiunea vectorului n = "; cin>>n; cout<<"Dati elementele vectorului \n"; for(i=1; i<=n; i++) { cout<<"a["<<i<<"]= "; cin>>a[i]; } bubble_sort(a,n); cout<<"Tabloul ordonat crescator \n"; for(i=1; i<=n; i++) cout<<a[i]<<" "; }
  22. Inainte sa vedem ce inseamna MySQL consider ca este important de stiut ce este SQL, si anume: SQL (Structured Query Language) este un standard international in cautarea si gasirea de informatii din bazele de date. MySQL (un sistem de management pentru baze de date) este, in fapt, un server SQL - el raspunde interogatiilor de informatie care sunt cuprinse in SQL. Bazele de date SQL se folosesc de obicei pentru a inmagazina informatii cum ar fi mesaje din forum, stiri, comentarii din guestbook, rezultate ale trecerilor in revista, etc. Puteti "comunica" cu MySQL folosind o mare varietate de limbaje de programare (PHP-ul fiind unul dintre cele mai des folosite). Asadar, MySQL este un server multi-user (mai multi utilizatori) si multi-thread (mai multe fire de executie), utilizeaza SQL, limbajul standard de interogare a bazelor de date din intreaga lume. MySQL este disponibil in mod public din 1996, dar istoria dezvoltarii sale incepe in 1979, sub o licenta Open Source, dar daca este nevoie sunt disponibile si licente comerciale. Pagina de baza pentru MySQL este: http://www.mysql.com Mai multe informatii puteti gasi accesand: http://ro.wikipedia.org/wiki/MySQL
  23. De ce să alegi programare în PHP? PHP rulează pe diferite platforme (Windows, Linux, Unix, Mac OS X, etc.) PHP este compatibil cu aproape toate serverele utilizate în prezent (Apache, IIS etc.) PHP suportă o gamă largă de baze de date PHP este gratuit. Descărcați-l din resursa oficială PHP: www.php.net PHP este ușor de învățat și rulează eficient pe partea de server De ce anume avem nevoie? Pentru a începe să utilizați PHP, parcurgeți pașii de mai jos: Identificați o gazdă web PHP gazdă și suport MySQL Instalați un server web pe propriul PC, apoi instalați PHP și MySQL Urmați instrucțiunile de instalare de pe situl oficial http://php.net/manual/en/install.php Un server web XAMPP ( Apache), un interpretor PHP și un SBGD (MySQL) Un editor de text (Notepad++) Un browser (Firefox) Ce vom realiza? vom crea un fișier *.php dintr-un fișier *.html deja existent vom adăuga stiluri utilizând CSS vom adăuga/include pagini dinamice (fișiere *.php) vom include un subsol, conținut și un meniu de navigare în paginile web. Fișierele basis.html și basis.css au fost create și au următorul conținut: basis.css *{ margin: 0px; padding: 0px; } body { font-size: 12pt; font-family: Verdana,Arial,sans-serif; } /* General fonts */ ul, li { margin-top: 0px; list-style-type: none; } p{ font-family: Verdana,Arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: normal; padding: 0px; } h1 { font: 1.25em Verdana,Arial,sans-serif; font-weight: bold; padding-bottom: 10px; } h2 { font: 1.25em Verdana,Arial,sans-serif; font-weight: bold; padding-bottom: 10px; color: red; } h3 { font: 1.25em Verdana,Arial,sans-serif; font-weight: bold; padding-bottom: 10px; } img { border: none; } /* Cont ainer */ #container { width: 970px; margin-top: 20px; margin-right: auto; margin-bottom: auto; margin-left: auto; } /* Hea der C ompon ents */ #header { border: 1px solid #999999; width: 970px; height: 115px; } /* Log o */ #logo { float: left; } /* Slo gan */ #slogan { position: absolute; width: auto; height: 30px; margin-top: 20px; margin-left: 280px; font-size: 2.3em; font-weight: bold; } /* Search bar */ #search { float: right; margin-top: 30px; clear: right; font-size: 0.8em; } /* Roo tline */ #rootline { font: normal 10px Verdana,Arial,sans-serif; padding-top: 5px; padding-bottom: 0px; margin-left: 0px; } /* Left part */ #left { float: left; min-height: 590px; padding-bottom: 0px; padding-top: 0px; position: relative; width: 200px; border: 1px solid #999999; margin-top: 10px; font-size: 1.1em; } /* Lan guage */ #languages { padding-top: 5px; padding-left: 16px; padding-bottom: 20px; } /* Meniu stanga */ #left-menu { text-align: left; margin-top: 40px; list-style-type: none; margin-left: 8px; } #left-menu a { text-decoration: none; } #left-menu a:hover { color: #666; } /* The main part of the page */ #middle { float: left; height: 580px; margin-left: 10px; width: 520px; border: 1px solid #999999; margin-top: 10px; padding: 5px 5px 5px 10px; overflow: auto; } /* Right */ #right { width: 202px; padding-top: 5px; padding-left: 5px; padding-right: 5px; padding-bottom: 0px; min-height: 585px; float: right; text-align: left; font-weight: normal; font-family: Verdana,Arial,sans-serif; border: 1px solid #999999; margin-top: 10px; position: relative; font-size: 0.8em; } /* Foo ter */ #footer { position: relative; top: 15px; font-family: Verdana,Arial,sans-serif; clear: both; text-align: right; color: #333; height: 25px; width: 970px; text-decoration: none; border: 1px solid #999999; font-size: 0.9em; padding-top: 5px; } basis.html <html> <head> <link rel="stylesheet" type="text/css" href="c ss/ba sis.c ss"> </head> <body> <div id="container"> <div id="header"> <div id="logo">###LOGO###</div> <div id="slogan">###SLOGAN###</div> <div id="search">###SEARCH###</div> </div > <div id="rootline">###ROOTLINE###</div> <div id="left"> <div id="languages">###LANGUAGES###</div> <div id="left-menu">###LEFT-MENU###</div> <div id="motto">###MOTTO###</div> </div > <div id="middle"> ###MIDDLE###</div> <div id="right"> ###RIGHT### <div id="topnews">###TOPNEWS###</div> </div > <div id="footer"> ###FOOTER### </div> </div> </body> </html>
  24. Ce este PHP? ... un acronim pentru “PHP: Hypertext Preprocessor” ...un limbaj de programare open-source, cu o largă răspândire în domeniul IT ... gratis pentru a fi descărcat și utilizat De ce este un limbaj atât de atractiv și popular? pentru că este suficient de puternic pentru a fi în centrul celui mai mare sistem de blogging pe web (WordPress)! pentru că este suficient de complex pentru a rula cea mai mare rețea socială (Facebook)! de asemenea, este destul de ușor să fii un programator începător de server-side! PHP... F i ș i e r e l e P H P p o t c o n ț i n e t e xt , c o d u r I H T M L , C S S , JavaScript și coduri PHP codurile PHP sunt executate pe server, iar rezultatul este returnat în browser ca un cod HTML simplu Fișierele PHP au extensia ".php" Vă prezint un exemplu de cod PHP (introduction.php) <!DOCTY PE h tml> <html> <body> <?php echo "My first PHP script!"; ?> </body> </html>
  25. Operatori logici Introducere Condițiile sunt o formă comodă de a lua decizii întrebându-ne dacă ceva are valoare Adevărat sau nu. Dar de multe ori o condiție nu e suficientă. Am putea dori să facem opusul. Sau de exemplu dacă dorim să luăm o decizie bazată pe turtle.xcor() și``turtle.ycor()`` atunci trebuie să le combinăm. Asta se poate rezolva cu operatori logici. Negarea unei declarații Dacă dorim ca ceva să fie Fals putem utiliza not. Este un operator logic: x = False if not x : print("condition met") else: print("condition not met") Exercițiu Țestoasa ne pune la dispoziție o funcție utilă pentru a ști dacă desenează sau nu: turtle.isdown(). Această funcție returnează Adevărat dacă țestoasa desenează. După cum am văzut mai devreme, funcțiile turtle.penup() și turtle.pendown() schimbă între desen și mișcare, sau doar mișcare fără a trasa nici o urmă. Putem scrie o funcție care înaintează doar dacă penița este ridicată? Soluție def stealthed_forward(distance): if not turtle.isdown(): turtle.forward(distance) Asta și aia sau altceva Doi operatori ușor de înțeles sunt and (și) și or (sau). Ei fac exact ce spune numele lor: if 1 < 2 and 4 > 2: print("condition met") if 1 > 2 and 4 < 10: print("condition not met") if 4 < 10 or 1 < 2: print("condition met") Nu ești limitat la un singur operator logic. Poți combina oricâți de mulți dorești. Exercițiu Mai devreme am pus țestoasa într-o închisoare circulară. De această dată să o punem într-o cutie. Dacă țestoasa merge mai mult de 100 pe axele X sau Y atunci întoarcem țestoasta înapoi spre centru. Soluție def forward(distance): while distance > 0: if (turtle.xcor() > 100 or turtle.xcor() < -100 or turtle.ycor() > 100 or turtle.ycor() < -100): turtle.setheading(turtle.towards(0,0)) turtle.forward(1) distance = distance - 1
×
×
  • Create New...