Help bring back Cain's Lair!

Help towards our goal of
$250 and help bring a game server back to Cain's Lair!!
Help us make our goal!
Help bring a game server back to Cain's Lair!

» Online Users: 17

0 members and 17 guests
No Members online
Most users ever online was 1,011, 20th Apr 2015 at 01:38 PM.

» Recent Reactions

Duke{CLR}'s reaction to
Cain's post in
Some Cain's Lair Ancient History
1st Jun 2017, 04:52 PM
Cain's reaction to
Rand{CLR}'s post in
Some Cain's Lair Ancient History
29th May 2017, 06:05 PM
Cain's reaction to
Faust's post in
Some Cain's Lair Ancient History
29th May 2017, 06:04 PM
Duke{CLR}'s reaction to
Cain's post in
Some Cain's Lair Ancient History
22nd May 2017, 10:32 PM
Cain's reaction to
Apache Warrior's post in
Some Cain's Lair Ancient History
22nd May 2017, 07:19 PM
Cain's reaction to
*THOR*'s post in
Some Cain's Lair Ancient History
22nd May 2017, 07:19 PM
Duke{CLR}'s reaction to
MR_MADHATTER's post in
Post your PC's!
10th May 2017, 08:12 AM
Slaughter's reaction to
MR_MADHATTER's post in
Post your PC's!
6th May 2017, 08:18 AM
Cain's reaction to
{CLR} Cobalt's post in
Cain's December 2016 Computer
24th Mar 2017, 04:41 PM
Duke{CLR}'s reaction to
*THOR*'s post in
Post your PC's!
12th Mar 2017, 04:59 PM
11th Mar 2017, 08:15 PM
11th Mar 2017, 10:09 AM
Duke{CLR}'s reaction to
Slaughter's post in
Epic Story Telling
7th Mar 2017, 07:55 AM
Duke{CLR}'s reaction to
Slaughter's post in
New machine
3rd Mar 2017, 01:14 PM
Slaughter's reaction to
*THOR*'s post in
Post your PC's!
27th Feb 2017, 08:51 AM
Duke{CLR}'s reaction to
Bon3z's post in
new video card help
30th Jan 2017, 08:11 PM
Duke{CLR}'s reaction to
{CLR} Cobalt's post in
New Kaby Lake build.
30th Jan 2017, 08:11 PM
Duke{CLR}'s reaction to
{CLR} Cobalt's post in
Youtube links not posting
30th Jan 2017, 08:10 PM
Duke{CLR}'s reaction to
Apache Warrior's post in
New Kaby Lake build.
29th Jan 2017, 02:30 PM
Duke{CLR}'s reaction to
{CLR} Cobalt's post in
New Kaby Lake build.
29th Jan 2017, 02:30 PM
Grisu's reaction to
Sirex's post in
New Kaby Lake build.
21st Jan 2017, 04:00 AM
Duke{CLR}'s reaction to
Cain's post in
New Kaby Lake build.
17th Jan 2017, 10:59 AM
Duke{CLR}'s reaction to
{CLR} Cobalt's post in
New Kaby Lake build.
17th Jan 2017, 10:59 AM
Slaughter's reaction to
Duke{CLR}'s post in
New Kaby Lake build.
17th Jan 2017, 07:58 AM
Slaughter's reaction to
K PhaNTOM's post in
Merry Happy Belated
31st Dec 2016, 07:34 PM
Slaughter's reaction to
Rand{CLR}'s post in
Merry Happy Belated
31st Dec 2016, 07:34 PM
Duke{CLR}'s reaction to
Cain's post in
Merry Happy Belated
28th Dec 2016, 12:52 PM
Duke{CLR}'s reaction to
Cain's post in
Cain's December 2016 Computer
21st Dec 2016, 06:27 PM
Slaughter's reaction to
Cain's post in
Cain's December 2016 Computer
21st Dec 2016, 09:05 AM
6th Dec 2016, 07:30 PM
Duke{CLR}'s reaction to
goldenfooler's post in
new video card help
29th Nov 2016, 10:32 AM
Slaughter's reaction to
Bliss's post in
Happy Thanksgiving Everyone
25th Nov 2016, 10:08 AM
Duke{CLR}'s reaction to
Jeffro's post in
Monthly Donations
17th Nov 2016, 04:28 PM
Duke{CLR}'s reaction to
Apache Warrior's post in
I have played with more CLRs in the last few days....
11th Nov 2016, 08:13 AM
Duke{CLR}'s reaction to
goldenfooler's post in
I have played with more CLRs in the last few days....
11th Nov 2016, 08:13 AM
Duke{CLR}'s reaction to
Qicmee's post in
I have played with more CLRs in the last few days....
11th Nov 2016, 08:13 AM
Duke{CLR}'s reaction to
{CLR} Cobalt's post in
Good times with some CLRs today!
10th Nov 2016, 08:48 AM
Duke{CLR}'s reaction to
*THOR*'s post in
CS:GO vs BF1 - Discussion
9th Nov 2016, 09:32 AM
Duke{CLR}'s reaction to
baconoclock's post in
I have played with more CLRs in the last few days....
8th Nov 2016, 10:28 PM
Duke{CLR}'s reaction to
Jeffro's post in
I have played with more CLRs in the last few days....
8th Nov 2016, 07:52 PM
Duke{CLR}'s reaction to
Cain's post in
Good times with some CLRs today!
8th Nov 2016, 07:52 PM
Duke{CLR}'s reaction to
Jeffro's post in
Good times with some CLRs today!
8th Nov 2016, 07:52 PM
Cain's reaction to
*THOR*'s post in
CS:GO vs BF1 - Discussion
8th Nov 2016, 06:40 PM
Cain's reaction to
Duke{CLR}'s post in
CS:GO vs BF1 - Discussion
8th Nov 2016, 06:39 PM
Duke{CLR}'s reaction to
*THOR*'s post in
CS:GO vs BF1 - Discussion
6th Nov 2016, 12:20 AM
Duke{CLR}'s reaction to
K PhaNTOM's post in
CS:GO vs BF1 - Discussion
2nd Nov 2016, 05:38 PM
Duke{CLR}'s reaction to
JohnyRico's post in
BF1 Field reports?
29th Oct 2016, 12:39 PM
Duke{CLR}'s reaction to
K PhaNTOM's post in
BF1 Field reports?
29th Oct 2016, 12:39 PM
Rand{CLR}'s reaction to
K PhaNTOM's post in
BF1 Field reports?
28th Oct 2016, 09:26 AM
Duke{CLR}'s reaction to
-Bar's post in
I buckled!!
25th Oct 2016, 09:47 PM

» Today's Birthdays

None

» Stats

Members: 6,098
Threads: 25,773
Posts: 265,821
Top Poster: Cain (41,395)
Welcome to our newest member, cankh17Jn2
Results 1 to 8 of 8
  1. #1
    Cain's Lair General Reconsnipe1's Avatar
    Join Date
    21st Aug 2008
    Location
    California
    Posts
    2,612
    Top Reaction: None (0/0)
     

    Default Need some JavaScript help if possible

    Hey guys! long time no see. I have been trying to wrap up a few more courses so I can finally graduate from college and just started a scripting class that is kicking my ass. I know a lot of you are computer savvy and may happen to know JavaScript. My assignment is to do a basic code for 4 different flags, Jamaica, Seychelles, Macedonia, Bahrain. I work in notepad++ but am brand new to this world and have no clue how to go about the assignment and troubleshoot. Is there anyone who could possibly give me some help if I sent them the code I have so far? It is a mess haha.
    Any help would be greatly appreciated!!!

    Hope to see you all in BF1 on a more fun note

    Recon

  2. #2
    Administrator Life Time Member Sirex's Avatar
    Join Date
    14th Jun 2005
    Location
    Ayrshire, Scotland
    Posts
    8,916
    Arcade Awards
    Asteroids Champion
    Top Reaction: None (0/0)
     

    Default

    Can't give you specifics but the best way to go about it for me would be...
    (sorry this is raw out of my head, so its a bit messy)

    Guessing the purpose is to get you thinking about storage and looping, because the data you need can be stored like that.
    (Know how many people I seen fail in my College days because they hard coded 'points' in to the program instead of using an array)
    So I'd have an array of bits with point arrays, so break the flag up into parts to draw.

    the black fill (dont need to map this)
    2x yellow stripes
    2x green triangles.
    OK how do you do those with out silly path calcs and stuff easy

    so you would have an array of

    {
    rot,
    lines = [
    [x,y],
    [x,y],
    [x,y],
    [x,y],
    [x,y],
    ],
    color,
    ]

    then use a set of loops to go over those steps.
    means you dont have a simple script and also you can adjust as needed, plus you can have multiple points in the line property not just 4 (bahrain)
    just need to step back and break them up into moves.

    so Jamiaca
    take the rectangle,
    fill green how you see fit (trust me)

    then using loops
    - rotate by rotate
    - new path
    - loop points
    -- draw a to b
    - close
    - fill


    So you would have this array (sorry i got lazy and just typed 1/2 it)
    [{
    rot: 0,
    lines: [],
    color: "#00ff00"
    },{
    //draw black triange
    rot: 59,
    lines: [
    [250,0],
    [250,290],
    [0,151]
    ],
    color: "#000000"
    },{
    //draw black triange on opposite side
    rot: 180,
    lines: [
    [250,0],
    [250,290],
    [0,151]
    ],
    color: "#000000"
    },{
    // draw yellow stripes
    [
    152,[
    [0,239],
    [0,272],
    [584,239],
    [584,272],
    (yellow)
    ],
    [
    119,[
    [0,239],
    [0,272],
    [584,239],
    [584,272],
    (yellow)
    ],
    //rotate back
    [-31,
    [],
    -1
    ],
    //draw circle (just an example)
    [0,
    [x,y,radius],
    (yellow)
    ]

    so your pseudo is:
    Code:
    flagsteps = (array above)
    for (i = 0; i < flagsteps .length; i++) begin
       flagstep = flagsteps[i]
       // Just rotate
       if color = -1 then
         canvas.rotate by flagstep.rot
       // Flood fill canvas
       else if flagstep.lines.length = 0 then
          canvas.fillcolor = flagstep.color
          canvas.fillrect(0, 0, canvas.width, canvas.height)
       // Lines and Circles
       else
          canvas.startpath
          // Just incase (you never know??, should never happen though
          if (flagstep.lines.length > 0) begin
                points = flagstep.lines[0]
                canvas.moveTo points[0] points[1]
                // Circle
                if points.length > 2 begin
                      //circle
                      canvas.arc(points[0],points[1],points[2],0,Math.PI*2,true) 
                // Funky shape, not just for squares!
                else
                      for (iline = 1; iline < flagstep.lines.length; iline++) begin
                            points = flagstep.lines[iline]
                            canvas.drawline from points[0] to points[1]
                      endfor
                endif
          endif
          canvas.endpath
          canvas.fillcolor = flagstep.color
          canvas.fill
       endif  
    endfor
    		
    so what you have here is a looping code (you can use for them all i think)
    it has an array of 'parts' to make,
    an instruction set (the -1 color) to just rotate
    and it will fill the canvas on no lines.

    really you dont need the rotate/arc stuff if you are willing to plot it,
    but i thought you'd put that in there for you incase you want to use it for seychelles or mecedonia (to keep the centre distances)

    for a non fancy version you would just have a list of points to draw in an array like before and loop it similar to that.

    What the above is doing is providing a step by step guide, and you are just looping over each step and following it.
    the 3 value array in line[0] makes it draw an circle
    a -1 color just rotates
    and no lines will fill canvas

    nice thing is because you ahve not programmed in step by step you can tweak each one.
    rotating is a bit ott but to be honest, its easier to work with a canvas when you rotate it to work with.
    think of your dinner plate, you rotate it to get to the stuff at the back for ease.
    because the canvas API will draw a stright line anyway this causes it to be ott,
    but when you use rotate it allows you to get proportions right if you where to scale say, its a pain to repoint some shapes (and also keeps pretty numbers in your script)

    plus if you really want to get fancy you could array all 4 flags flagsteps into one and loop over those and draw them side by side.
    have like
    [{
    name: "placename",
    steps: ...
    canvasid: divFlag1
    },{
    name: "placename2",
    steps: ...
    canvasid: divFlag2
    },

    and loop that settings variables up etc




    I'm not insane. I'm just overwhelming!

    ·····••••• Support Cainslair. Donate here!•••••·····
    ·····••••• and get extra options! •••••·····

  3. #3
    Cain's Lair General Life Time Member goldenfooler's Avatar
    Join Date
    26th Feb 2006
    Location
    Hawthorne NJ
    Posts
    9,797
    Top Reaction: None (0/0)
     

    Default


  4. #4
    Administrator Life Time Member Sirex's Avatar
    Join Date
    14th Jun 2005
    Location
    Ayrshire, Scotland
    Posts
    8,916
    Arcade Awards
    Asteroids Champion
    Top Reaction: None (0/0)
     

    Default

    Quote Originally Posted by goldenfooler View Post
    Lol know my Boss does that...
    Always breaks out the metaphorical popcorn when he throws a problem my way.




    I'm not insane. I'm just overwhelming!

    ·····••••• Support Cainslair. Donate here!•••••·····
    ·····••••• and get extra options! •••••·····

  5. #5
    Cain's Lair General Life Time Member goldenfooler's Avatar
    Join Date
    26th Feb 2006
    Location
    Hawthorne NJ
    Posts
    9,797
    Top Reaction: None (0/0)
     

    Default

    i am going to send this to my nephew and see if he can understand it.

  6. #6
    Administrator Life Time Member Sirex's Avatar
    Join Date
    14th Jun 2005
    Location
    Ayrshire, Scotland
    Posts
    8,916
    Arcade Awards
    Asteroids Champion
    Top Reaction: None (0/0)
     

    Default

    Lemme know if he can, raw out my head stuffs pretty jumbled up...
    Though this ones pretty ok.

    Should see my written stuff for things I do... eventually even I cant make head nor tail of it.




    I'm not insane. I'm just overwhelming!

    ·····••••• Support Cainslair. Donate here!•••••·····
    ·····••••• and get extra options! •••••·····

  7. #7
    Cain's Lair General Life Time Member goldenfooler's Avatar
    Join Date
    26th Feb 2006
    Location
    Hawthorne NJ
    Posts
    9,797
    Top Reaction: None (0/0)
     

    Default

    Quote Originally Posted by Sirex View Post
    Lemme know if he can, raw out my head stuffs pretty jumbled up...
    Though this ones pretty ok.

    Should see my written stuff for things I do... eventually even I cant make head nor tail of it.
    wait you didn't write the bf code did you

  8. #8
    Administrator Life Time Member Sirex's Avatar
    Join Date
    14th Jun 2005
    Location
    Ayrshire, Scotland
    Posts
    8,916
    Arcade Awards
    Asteroids Champion
    Top Reaction: None (0/0)
     

    Default

    Lol na i had it all would work

    I may have a very messy documentation/note style but I have alot of care and thought in what I code.

    Was actually told ive got a very unique but accutate and thought out coding style.
    So much so I helped my brother one time and his lecturer said "your brother gave you hints huh?"

    Can't really see it myself but i do code a little diff from most folk.
    I see stuff on the net and if I use it you can see its not mine in the code.

    Lectures used to tell me I had a knack for getting square pegs into round holes... in a good way.




    I'm not insane. I'm just overwhelming!

    ·····••••• Support Cainslair. Donate here!•••••·····
    ·····••••• and get extra options! •••••·····

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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