Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Are views and levels possible with JavaScript?

    I was just kind of curious if it would be possible to make views with javascript. Say you wanted to make a game kind of like mario how would you make it so it scrolls with the object as you move throught the room? Also i was wondering how you would load the next level when you finish the one you are on?

    thank you,
    cgwalls

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Entirely possible, through various ways. You can animate pretty much through the canvas element, VML or SVG - you could even generate HTML or actual graphics (BMP are simple to generate but not so small in memory, as an example). You can load levels through creating script elements that load JavaScript code for the next level, or you can use XMLHttpRequest, or you can use a form (making each level a separate HTML page) etc. The technique you use for the graphics part is pretty much the same as for desktop or Flash games, only a few years behind in technology level.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok so i kind of get how to load the levels but i'm not really quite sure how to get the level to scroll as you move through it. i was thinking you would make a variable go up every time you move and check if the variable is at a certain number to move the background or something. but then if there were enemies farther in the level how would i get those to appear when i get far enough in the room. i'm really confused lol.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    It is called learning how to program and thinking how things work.

    You set up conditions. If player is in X1 area, I do this. If player is in X2 area I do this.

    If I were you, I would worry less about enemies at this time and get a character moving through some screen.

    Here is an example for you to start out with: http://ajaxpatterns.org/wiki/index.p...rite#Solutions

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •