Search Results

Search found 1513 results on 61 pages for 'canvas'.

Page 12/61 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • 2D vector graphic html5 framework

    - by Yury
    I trying to find html5 game framework by following criteria: 1)Real good performance. 2)Good support of vector graphic( objects which contains canvas elements -line, rec,bezierCurve etc.) 3)Easy port to mobile. Optional- Physics Engine. I found 1)Pixi.js- it looks like real good, but i didn't find any info about "vector objects" support. 2) i found "vector objects" support in paper.js I need something like these: http://paperjs.org/examples/chain/ and http://paperjs.org/examples/path-intersections/. But it looks like paper.js- not so good performance as pixi.js. And it is not game engine. Is there any good framework meets these requirements? P.S. I found similar question here Which free HTML5-based game engine meets these requirements?. But it was a long time ago. A lot of new things were created since 2011.

    Read the article

  • Defining the track in a 2D racing game

    - by Ivan
    I am designing a top-down racing game using canvas (html5) which takes a lot of inspiration from Micro Machines. In MM, cars can move off the track, but they are reset/destroyed if they go too far. My maths knowledge isn't great, so I'm finding it hard to separate 3D/complex concepts from those which are directly relevant to my situation. For example, I have seen "splines" mentioned, is this something I should read up on or is that overkill for a 2D game? Could I use a single path which defines the centre of the track and check a car's distance from this line? A second path might be required as a "racing line" for AI. Any advice on methods/techniques/terms to read up on would be greatly appreciated.

    Read the article

  • Where to start, to develop an online Backgammon game?

    - by Matt V.
    I would like to develop a backgammon game to play against other players online, as a way of learning more Javascript/jQuery and a little game development. I'm a web developer and most of my experience is in PHP. I have minimal Javascript experience and no game development experience. Where should I start? Are there any particular books, tutorials, libraries, or frameworks that would help give me a jumpstart? As a beginner, am I better of using the DOM or Canvas?

    Read the article

  • How to move an object using X and Y coordinates in JavaScript

    - by Geroy290
    I am making a 2d game with JavaScript and HTML5 and am trying to move an image that I have drawn with JavaScript like so: //canvas var c = document.getElementById("gameCanvas"); var ctx = c.getContext("2d"); //baseball var baseball = new Image(); baseball.onload = function() { ctx.drawImage(baseball, 400, 425); }; baseball.src = "baseball2.png"; I'm not sure how I would move it though, I have seen many people seem to just type something like ballX and ballY but I don't understand where the actual x and y definition comes from. Here is my code so far: http://jsfiddle.net/xRfua/ I have a different image source but it is a local source so I couldn't include it. Thanks in a dvance for any help!

    Read the article

  • How do I make a simple level system?

    - by ROROX
    I've been learning programming for a while and things are slow but steady. I only have a couple experiments that look something like a game (JavaScript,HTML5,CANVAS). One of the things I would like to establish this early in my process though is a basic level system to my games. I'm thinking like Atari, NES type simple. mainMenu , level1 , level2 , ... Later I'll work on including such screens as; titleScreen , pause , highScore. But for now just looking for the basics. Any good articles/tutorial links would help. Or just a snippet of code I can look over. Thank you kindly :)

    Read the article

  • Creating several instances of the same object, and selecting only one

    - by hustlerinc
    I'm playing around with making a puzzle game, haven't done that much before I run into my first problem. Basically, I want to create a certain amount of the same object/function. But without hardcoding the different instances. I think maybe an array is a good idea? and then a for loop to push the objects in? And then I need to be able to select one of these objects by clicking on it, how would I do that? How do I know which ball in the array was clicked? A loop again? I made a jsFiddle example (you need to click the orange ball to select, then you can move it around by clicking the canvas). This is what I want to do, but with more balls. How would you solve this? Help appreciated.

    Read the article

  • Drawing to the canvas

    - by Mattl
    I'm writing an android application that draws directly to the canvas on the onDraw event of a View. I'm drawing something that involves drawing each pixel individually, for this I use something like: for (int x = 0; x < xMax; x++) { for (int y = 0; y < yMax; y++){ MyColour = CalculateMyPoint(x, y); canvas.drawPoint(x, y, MyColour); } } The problem here is that this takes a long time to paint as the CalculateMyPoint routine is quite an expensive method. Is there a more efficient way of painting to the canvas, for example should I draw to a bitmap and then paint the whole bitmap to the canvas on the onDraw event? Or maybe evaluate my colours and fill in an array that the onDraw method can use to paint the canvas? Users of my application will be able to change parameters that affect the drawing on the canvas. This is incredibly slow at the moment.

    Read the article

  • Filling a region draws it off canvas

    - by Xanyx
    Hi Using the following code in Delphi 2007: procedure TfrmTest.PaintBox1Paint(Sender: TObject); const Rect_Size = 10; begin PaintBox1.Canvas.Brush.Color := clYellow; PaintBox1.Canvas.FillRect(Rect(0, 0, PaintBox1.width, PaintBox1.height)); PaintBox1.Canvas.Brush.Color := clRed; DrawARect(PaintBox1.Canvas, 0, 0, Rect_Size, Rect_Size); end; procedure TfrmTest.DrawARect(ACanvas: TCanvas; iLeft, iTop, iWidth, iHeight: Integer); var rgnMain: HRGN; begin rgnMain := CreateRectRgn(iLeft, iTop, iLeft + iWidth, iTop + iHeight); try SelectClipRgn(ACanvas.handle, rgnMain); ACanvas.FillRect(ACanvas.ClipRect); SelectClipRgn(ACanvas.handle, 0); finally DeleteObject(rgnMain); end; end; I get this: (Yellow area shows boundaries of PaintBox1). HMMM, NOT ALLOWED TO POST IMAGE Please go to: http://www.freeimagehosting.net/uploads/62cf687d29.jpg (Linked image shows a form with a yellow box [PaintBox1] in the center. However my red rectange [rgnMain] has been drawn at pos 0,0 on the form) My expectation was that the red rectangle would be at the top left of the PaintBox1 canvas, not the form's canvas. Why is it not? Can regions only be used with controls that have a Windows handle? Thanks

    Read the article

  • Z axis in isometric tilemap

    - by gyhgowvi
    I'm experimenting with isometric tile maps in JavaScript and HTML5 Canvas. I'm storing tile map data in JavaScript 2D array. // 0 - Grass // 1 - Dirt // ... var mapData = [ [0, 0, 0, 0, 0], [0, 0, 1, 0, 0, ... ] and draw for(var i = 0; i < mapData.length; i++) { for(var j = 0; j < mapData[i].length; j++) { var p = iso2screen(i, j, 0); // X, Y, Z context.drawImage(tileArray[mapData[i][j]], p.x, p.y); } } but this function mean's all tile Z axis is equal to zero. var p = iso2screen(i, j, 0); Maybe anyone have idea and how to do something like mapData[0][0] Z axis equal to 3 mapData[5][5] Z axis equal to 5? I have idea: Write function for grass, dirt and store this function to 2D array and draw and later mapData[0][0].setZ(3); But it is good idea to write functions for each tiles?

    Read the article

  • Glitch-free cross-fades in HTML5

    - by Alexander Gladysh
    In my HTML5 canvas game, I need to cross-fade two sprites which have some glow around them. (Glow is backed into sprites.) Initially, the first sprite is visible. During the cross-fade the first sprite should vanish, and be replaced with the second one. How exactly the cross-fade is done — does not matter, as long as it is smooth and there are no visual glitches. I've tried two techniques: During the cross-fade I simultaneously interpolate alpha of the first sprite from 1.0 to 0.0, and alpha of the second sprite — from 0.0 to 1.0. With this technique I can see background in the middle of the cross-fade. That's because both sprites are semi-transparent most of the time. During the cross-fade I first interpolate alpha of the second sprite from 0.0 to 1.0 (first sprite alpha is at 1.0), and then interpolate alpha of the first sprite from 1.0 to 0.0. With this technique background is not seen, but the glow around sprites flashes during the cross-fide — when both sprites are near the full visibility. In non-HTML5 game I'd use shaders to do cross-fade separately in RGB and alpha channels. Is there a trick to do the cross-fade I need in HTML5 without visual glitches?

    Read the article

  • How to shift a vector based on the rotation of another vector?

    - by bpierre
    I’m learning 2D programming, so excuse my approximations, and please, don’t hesitate to correct me. I am just trying to fire a bullet from a player. I’m using HTML canvas (top left origin). Here is a representation of my problem: The black vector represent the position of the player (the grey square). The green vector represent its direction. The red disc represents the target. The red vector represents the direction of a bullet, which will move in the direction of the target (red and dotted line). The blue cross represents the point from where I really want to fire the bullet (and the blue and dotted line represents its movement). This is how I draw the player (this is the player object. Position, direction and dimensions are 2D vectors): ctx.save(); ctx.translate(this.position.x, this.position.y); ctx.rotate(this.direction.getAngle()); ctx.drawImage(this.image, Math.round(-this.dimensions.x/2), Math.round(-this.dimensions.y/2), this.dimensions.x, this.dimensions.y); ctx.restore(); This is how I instanciate a new bullet: var bulletPosition = playerPosition.clone(); // Copy of the player position var bulletDirection = Vector2D.substract(targetPosition, playerPosition).normalize(); // Difference between the player and the target, normalized new Bullet(bulletPosition, bulletDirection); This is how I move the bullet (this is the bullet object): var speed = 5; this.position.add(Vector2D.multiply(this.direction, speed)); And this is how I draw the bullet (this is the bullet object): ctx.save(); ctx.translate(this.position.x, this.position.y); ctx.rotate(this.direction.getAngle()); ctx.fillRect(0, 0, 3, 3); ctx.restore(); How can I change the direction and position vectors of the bullet to ensure it is on the blue dotted line? I think I should represent the shift with a vector, but I can’t see how to use it.

    Read the article

  • ImageData of an externally loaded Image?

    - by sri
    I load an external image and draw it on the Canvas element like so: var canvas = document.getElementById('canvas1'); var context = canvas.getContext('2d'); var image = new Image(); image.onload = function(evt) { context.drawImage(evt.target, 0, 0); } image.src = "test.jpg"; But I want to get the ImageData. So after calling context.drawImage, I do this: var imagedata = canvas.getImageData(); manipulate(imagedata); // modifies imagedata.data context.putImageData(imagedata, 0, 0); Is that the only way to get the imageData of an externally loaded image? Drawing the image on canvas & then getting the imagedata seems awfully slow. Am I missing something? Thanks!

    Read the article

  • drawImage don't work on chrome extention

    - by shrwea
    I use canvas drawImage in popup.html. But it doesn't work. Please advise me. popup.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <canvas id="test"></canvas> <script src="test.js"></script> </body> </html> test.js var image = document.createElement("img"); image.src = "test.png"; image.onload = function(){ var canvas = document.getElementById('test'); var ctx = canvas.getContext('2d'); ctx.drawImage(image, 0, 0); }

    Read the article

  • Issues with shooting in a HTML5 platformer game

    - by fnx
    I'm coding a 2D sidescroller using only JavaScript and HTML5 canvas, and in my game I have two problems with shooting: 1) Player shoots continous stream of bullets. I want that player can shoot only a single bullet even though the shoot-button is being held down. 2) Also, I get an error "Uncaught TypeError: Cannot call method 'draw' of undefined" when all the bullets are removed. My shooting code goes like this: When player shoots, I do game.bullets.push(new Bullet(this, this.scale)); and after that: function Bullet(source, dir) { this.id = "bullet"; this.width = 10; this.height = 3; this.dir = dir; if (this.dir == 1) { this.x = source.x + source.width - 5; this.y = source.y + 16; } if (this.dir == -1) { this.x = source.x; this.y = source.y + 16; } } Bullet.prototype.update = function() { if (this.dir == 1) this.x += 8; if (this.dir == -1) this.x -= 8; for (var i in game.enemies) { checkCollisions(this, game.enemies[i]); } // Check if bullet leaves the viewport if (this.x < game.viewX * 32 || this.x > (game.viewX + game.tilesX) * 32) { removeFromList(game.bullets, this); } } Bullet.prototype.draw = function() { // bullet flipping uses orientation of the player var posX = game.player.scale == 1 ? this.x : (this.x + this.width) * -1; game.ctx.scale(game.player.scale, 1); game.ctx.drawImage(gameData.getGfx("bullet"), posX, this.y); } I handle removing with this function: function removeFromList(list, object) { for (i in list) { if (object == list[i]) { list.splice(i, 1); break; } } } And finally, in the main game loop I have this: for (var i in game.bullets) { game.bullets[i].update(); game.bullets[i].draw(); } I have tried adding if (game.bullets.length > 0) to the main game loop before the above draw&update calls, but I still get the same error.

    Read the article

  • Why does my goblin only choose a walk direction once?

    - by Eogcloud
    I'm working on a simpe 2d canvas game that has a small goblin sprite who I want to get pathing around the screen. What I originally tried was a random roll that would choose a direction, the goblin would walk that direction. It didnt work effectively, he sort of wobbled in one spot. Here's my current apporach but he only runs in a rundom direction and doesnt change. What am I doing wrong? Here's all the relevant code to the goblin object and movement. var goblin = { speed: 100, pos: [0, 0], dir: 1, changeDir: true, stepCount: 0, stepTotal: 0, sprite: new Sprite( goblinImage, [0,0], [30,45], 6, [0,1,2,3,2,1], true) }; function getNewDir(){ goblin.dir = Math.floor(Math.random()*4)+1; }; function checkGoblinMovement(){ if(goblin.changeDir){ goblin.changeDir = false; goblin.stepCount = 0; goblin.stepTotal = Math.floor(Math.random*650)+1; getNewDir(); } else { if(goblin.stepCount === goblin.stepTotal){ goblin.changeDir = true; } } }; function update(delta){ healthCheck(); if(isGameOver){ gameOver(); } if(!isGameOver){ updateCharLevel(); keyboardInput(delta); moveGoblin(delta); checkGoblinMovement(); goblin.sprite.update(delta); //update sprites if(mainChar.kills!=0 && bloodReady){ for(var i=0; i<bloodArray.length; i++){ bloodArray[i].sprite.update(delta); } } //collision detection if(collision(mainChar, goblin)) { combatOutcome(combatEvent()); combatCleanup(); } } }; function main(){ var now = Date.now(); var delta = (now - then)/1000; if(!isGameOver){ update(delta); } draw(); then = now; }; function moveGoblin(delta){ goblin.stepCount++; if(goblin.dir === 1){ goblin.pos[1] -= goblin.speed * delta* 2; if(goblin.pos[1] <= 85){ goblin.pos[1] = 86; } } if(goblin.dir === 2){ goblin.pos[1] += goblin.speed * delta; if(goblin.pos[1] > 530){ goblin.pos[1] = 531; } } if(goblin.dir === 3){ goblin.pos[0] -= goblin.speed * delta; if(goblin.pos[0] < 0){ goblin.pos[0] = 1; } } if(goblin.dir === 4){ goblin.pos[0] += goblin.speed * delta* 2; if(goblin.pos[0] > 570){ goblin.pos[0] = 571; } } };

    Read the article

  • Is it possible to take a screenshot of a web page with Javascript or HTML5/Canvas?

    - by Ryan Kearney
    Is there a way I could insert some code into a page that would take a screenshot of what the user sees in the browser window, then upload that image via a web form of some sort? I'm working on a clone of a pay-to-use service that lets you install a widget on a web page which in turn allows viewers to report bugs in the sites layout. Currently they use a Java applet to take the screenshot, which, in my opinion, is probably the worst way to go about it (aside from requiring the user to install a plugin) Is there a javascript/flash/other alternative? Thanks

    Read the article

  • Code is not the best way to draw

    - by Bertrand Le Roy
    It should be quite obvious: drawing requires constant visual feedback. Why is it then that we still draw with code in so many situations? Of course it’s because the low-level APIs always come first, and design tools are built after and on top of those. Existing design tools also don’t typically include complex UI elements such as buttons. When we launched our Touch Display module for Netduino Go!, we naturally built APIs that made it easy to draw on the screen from code, but very soon, we felt the limitations and tedium of drawing in code. In particular, any modification requires a modification of the code, followed by compilation and deployment. When trying to set-up buttons at pixel precision, the process is not optimal. On the other hand, code is irreplaceable as a way to automate repetitive tasks. While tools like Illustrator have ways to repeat graphical elements, they do so in a way that is a little alien and counter-intuitive to my developer mind. From these reflections, I knew that I wanted a design tool that would be structurally code-centric but that would still enable immediate feedback and mouse adjustments. While thinking about the best way to achieve this goal, I saw this fantastic video by Bret Victor: The key to the magic in all these demos is permanent execution of the code being edited. Whenever a parameter is being modified, everything is re-executed immediately so that the impact of the modification is instantaneously visible. If you do this all the time, the code and the result of its execution fuse in the mind of the user into dual representations of a single object. All mental barriers disappear. It’s like magic. The tool I built, Nutshell, is just another implementation of this principle. It manipulates a list of graphical operations on the screen. Each operation has a nice editor, and translates into a bit of code. Any modification to the parameters of the operation will modify the bit of generated code and trigger a re-execution of the whole program. This happens so fast that it feels like the drawing reacts instantaneously to all changes. The order of the operations is also the order in which the code gets executed. So if you want to bring objects to the front, move them down in the list, and up if you want to move them to the back: But where it gets really fun is when you start applying code constructs such as loops to the design tool. The elements that you put inside of a loop can use the loop counter in expressions, enabling crazy scenarios while retaining the real-time edition features. When you’re done building, you can just deploy the code to the device and see it run in its native environment: This works thanks to two code generators. The first code generator is building JavaScript that is executed in the browser to build the canvas view in the web page hosting the tool. The second code generator is building the C# code that will run on the Netduino Go! microcontroller and that will drive the display module. The possibilities are fascinating, even if you don’t care about driving small touch screens from microcontrollers: it is now possible, within a reasonable budget, to build specialized design tools for very vertical applications. Direct feedback is a powerful ally in many domains. Code generation driven by visual designers has become more approachable than ever thanks to extraordinary JavaScript libraries and to the powerful development platform that modern browsers provide. I encourage you to tinker with Nutshell and let it open your eyes to new possibilities that you may not have considered before. It’s open source. And of course, my company, Nwazet, can help you develop your own custom browser-based direct feedback design tools. This is real visual programming…

    Read the article

  • General directions on developing a server side control system for JS/Canvas Action RPG

    - by Billy Ninja
    Well, yesterday I asked on anti-cheat JS, and confirmed what I kind of already knew that it's just not possible. Now I wanna measure roughly how hard it is to implement a server side checking that is agnostic to client input, that does not mess with the game experience so much. I don't wanna waste to much resource on this matter, since it's going to be initially a single player game, that I may or would like to introduce some kind of ranking, trading system later on. I'd rather deliver better more cool game features instead. I don't wanna have to guarantee super fast server response to keep the game going lag free. I'd rather go with more loose discrete control of key variables and instances. Like store user's action on a fifo buffer on the client, and push that actions to the server gradually. I'd love to see a elegant, generic solution that I could plug into my client game logic root (not having to scatter treatments everywhere in my client js) - and have few classes on Node.js server that could handle that - without having to mirror/describe all of my game entities a second time on the server.

    Read the article

  • HTML5-Canvas: worth using ImpactJS or other framework?

    - by John
    I've been making an HTML5 game without any type of external framework. I haven't found a reason to use one so far. However, there is one thing I'm wondering about. On my Galaxy Nexus, I get about ~40fps. While that would usually be a decent framerate, my game is a rather fast paced game with a gamepad. Because of this, it feels very unsatisfying to play when not capped at 60fps. Are there frameworks out there that can improve performance without toning down on graphics? Or is there something I could do myself without necessarily having to use a framework? I've looked over the basic things such as sticking to integer coordinates, but I didn't see an increase in performance whatsoever? I did some testing with jsperf and results were virtually identical. Does this depend more on the browser?

    Read the article

  • Binding the position and size of a UserControl inside a Canvas in WPF

    - by John
    Hi. We have dynamically created (i.e. during runtime, via code-behind) UserControls inside a Canvas. We want to bind the position (Canvas.Left and Canvas.Top) and width of those sizable and draggable UserControls to a ObservableCollection<. How would we achieve this if the Usercontrol is contained in a DataTemplate which in turn is used by a ListBox whose DataContext is set to the collection we want to bind to? In other words, how do we bind a control's position and size that doesn't exist in XAML, but in code only (because it's created by clicking and dragging the mouse)? Notice that the collection can be empty or not empty, meaning that the size and position stores in a collection item must be correctly bound to so that the UserControl can be sized and positioned correctly in the Canvas - via DataBinding. Is this possible?

    Read the article

  • Silverlight Canvas doesn't support KeyDown?

    - by chakrit
    I have this: <Canvas x:Name="LayoutRoot" KeyDown="LayoutRoot_KeyDown"> </Canvas> In a newly-minted Ag 3 application in VS2008. I simply changed the default <Grid /> to <Canvas /> and added a KeyDown handler that pops a MessageBox. But no matter how I tried, the KeyDown event just would never, ever fires. Is it simply that <Canvas /> doesn't support KeyDown or am I doing something wrong?

    Read the article

  • Deeplinking using GWT History Token within a Facebook iFrame Canvas

    - by Stevko
    I would like to deep link directly to a GWT app page within a Facebook iFrame Canvas. The first part is simple using GWT's History token with URLs like: http://www.example.com/MyApp/#page1 which would open page1 within my app. Facebook Apps use an application url like: http://apps.facebook.com/myAppName which frames my Canvas Callback URL http://www.example.com/MyApp/ Is there a way to specify a canvas callback url (or bookmark url) which will take the user to a specific page rather than the index page? Why? you may ask. Besides all the benefits of deep links... I want the "Go To Application" url to take users to an index page w/ marketing material (the canvas callback url) I want the "Bookmark URL" to take (likely returning) users to a login page and bypass downloading the marketing content (and that huge SWF file).

    Read the article

  • Binding a Viewbox to a Canvas

    - by Bjarne
    I'm trying to bind a Viewbox to Canvas that is created dynamically like so: <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Viewbox> <ContentPresenter Content="{Binding Canvas}"/> </Viewbox> </DockPanel> </DataTemplate> </ListBox.ItemTemplate> This works fine as long as the Canvas doesn't have any children, but as soon at the Canvas has children it's not shown. What am I missing here?

    Read the article

  • plt-scheme : catching mouse click event on canvas

    - by Thura
    I am writing a tic-tac-toe game in plt-scheme as my AI course project. The idea for gui is a grid with 9 boxes, each with a canvas, using panes ... When the user click on a canvas, 'X' or 'O' will be drawn accordingly ... The question is how can I catch mouse click event on canvas? I found out I need to use on-event, but still don't know how? Any clues?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >