Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: viewport y #32

Open
err0 opened this issue Jan 20, 2012 · 3 comments
Open

Question: viewport y #32

err0 opened this issue Jan 20, 2012 · 3 comments

Comments

@err0
Copy link
Contributor

err0 commented Jan 20, 2012

I can't seem to get a viewport to render only on the bottom part of the canvas. I can get it to render on only the top part just fine.
canvas size is 500,320

// render top half - works
viewport_top = new jaws.Viewport({max_x: width*32, max_y: height*32, height:160 })
//expected this to render to the  bottom half of the canvas
viewport_bottom = new jaws.Viewport({max_x: width*32, max_y: height*32, height:160, y: 160 }) 
@err0
Copy link
Contributor Author

err0 commented Jan 20, 2012

the problem I am trying to solve with this is that I have a tilemap of tree sprites. the player is centered on the full "ground" tilemap and I want to draw the sprites with y < player first, then the player, then the y > player sprites.

I think I'll try using TileMap.atRect next and simplify my viewports.

@ippa
Copy link
Owner

ippa commented Jan 21, 2012

Pretty busy this weekend but i think we need to talk about this on irc ..not totally sure what you mean.. Im "ippa" on freenode

@err0
Copy link
Contributor Author

err0 commented Jan 21, 2012

Here is what I ended up doing. It's working pretty well.

viewport.drawTileMap( tile_map_b )  //collision layer
viewport.drawTileMap( tile_map) // grass & ground
viewport_t.draw( tree_map.atRect(jaws.Rect(player.x - 250, player.y - 160, 500, 128 ))) //trees when above player on screen
viewport_t.draw( player ) //player centered on canvas
viewport_b.draw( tree_map.atRect(jaws.Rect(player.x - 250, player.y + 32, 500, 160 ))) //trees when below player on screen

I am still curious if there is a way to offset a viewport away from top left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants