Results 1 to 7 of 7

Thread: Anyone experienced in Matlab?

  1. #1
    west philadelphia born n raised ech0's Avatar
    Join Date
    Feb 2007
    Location
    Killadelphia
    Posts
    1,171

    Anyone experienced in Matlab?

    Hey guys,
    I am currently trying to teach myself Matlab for one of my classes where they're having us finish out the semester with a project. I am writing code for a Snake game. I was wondering if anyone has experience using Matlab and could provide help with the coding and such. I am not asking for one to write the code for me but anyone that can provide help if I have questions.

    If you have Matlab experience and are willing to help with some tips send me a message or email.

    teh r!g

    E6600 w/ Zalman 9700NT @ 3.6 | EVGA 8800 GTX @ 628/1000 | EVGA 680i A1 | 2x1gigs Mushkin XtremePerformance DDR2 800 | 250gig SATAII Barracuda | X-Fi ExtremeGamer Pro Fatal1ty Edition | 750w Toughpower | Aurora 570 Case | 3dMark06 - 13,110
    Design By Humans

  2. #2
    NOPE BuddhistSoldier's Avatar
    Join Date
    Feb 2006
    Location
    All over Canada
    Posts
    1,771

    Re: Anyone experienced in Matlab?

    I promptly rammed/dumped everything about matlab after finishing my physics semester where they used it.

  3. #3
    ... Speedde423's Avatar
    Join Date
    Jan 2005
    Posts
    4,072

    Re: Anyone experienced in Matlab?

    I've done a fair amount of number crunching, and some simulations. I'm not sure if what I know will help with game programming, but I'd give it a shot.

    Google would be your best friend. It would give you some files for a good start.

  4. #4
    west philadelphia born n raised ech0's Avatar
    Join Date
    Feb 2007
    Location
    Killadelphia
    Posts
    1,171

    Re: Anyone experienced in Matlab?

    Yes, I already have a script of an existing Snake game, but I'm having trouble deciphering what everything means and whats being called and such.

    teh r!g

    E6600 w/ Zalman 9700NT @ 3.6 | EVGA 8800 GTX @ 628/1000 | EVGA 680i A1 | 2x1gigs Mushkin XtremePerformance DDR2 800 | 250gig SATAII Barracuda | X-Fi ExtremeGamer Pro Fatal1ty Edition | 750w Toughpower | Aurora 570 Case | 3dMark06 - 13,110
    Design By Humans

  5. #5
    ... Speedde423's Avatar
    Join Date
    Jan 2005
    Posts
    4,072

    Re: Anyone experienced in Matlab?

    If it's not long, print it out and draw arrows to what goes where, preferably in different colors. And if you want, either post it here, or PM me with what you're having problems with and I'll see if I can tell what's going on.

    You might also want to find the code for a similar game on BASIC or the code for the TI-83 calculator to see more examples.

    You're almost never going to be able to follow someone else's code exactly, so it's best not to try unless you have to. Just get an idea on where everything goes.

  6. #6
    west philadelphia born n raised ech0's Avatar
    Join Date
    Feb 2007
    Location
    Killadelphia
    Posts
    1,171

    Re: Anyone experienced in Matlab?

    Alright, so far I have this

    Code:
    function checkpoint34()
    global x2 y2 x y dir
    
    x=randi(25);
    y=randi(25);           %sets random food, dir, and snake pts
    x2=randi(25);
    y2=randi(25);
    dir=randi(4);
    
    figure('Name', 'Kees''s Snake',... 
        'Numbertitle', 'off',... 
        'Menubar', 'none',...
        'Color', [0 1 0],...
        'DoubleBuffer','on',...
        'KeyPressFcn', @movement);
    
        function movement(~,event)      % movement function, arrow keys
            switch event.Character
                case 28 %Left
                    dir=1;
                case 29 %Right
                    dir=2;
                case 30 %Up
                    dir=3;
                case 31 %Down
                    dir=4;
            end
        end
            while x<=25 && x>=0 && y<=25 && y>=0 %Start of loop; sets parameters
            clf
            food(x2,y2)
            draw_snake1(x,y) %Calling draw_snake function
                    switch dir
                        case 1 %Left
                            x=x-1;
                        case 2 %Right
                            x=x+1;
                        case 3 %Up
                            y=y+1;
                        case 4 %Down
                            y=y-1;
                    end
                    pause (.2)
                            if x2==x && y2==y %if snake=food, set new food coordinates
                               text(10.9,12.5, 'CHOMP!')
                               x2=randi(25);
                               y2=randi(25);           
                            end
                    
            end
            text(10.9,12.5,'You Lose!') %Out of parameters, hits wall, display 'You Lose!'
            
    end
    Code:
    function draw_snake1(x,y)  %draws the snake as a single square
    hold on
    plot(x,y,'sk','MarkerFaceColor','k') %Plot x and y with a black square
    axis([0, 25, 0, 25]) %Set dimensions of plot to a 25x25 box
    color('red')
    box('on')
    end
    Code:
    function food(x2,y2) %draws the food as a single square
    hold on
    plot(x2,y2, 'rs','MarkerFaceColor','r')
    end
    It's very simple code as the final product isn't suppose to be some very complex. Right now, I need to convert the draw_snake1(x,y) to plot the snake as a 25x25 array and have the snake move direction within the array and grow. I have no idea where to start.

    teh r!g

    E6600 w/ Zalman 9700NT @ 3.6 | EVGA 8800 GTX @ 628/1000 | EVGA 680i A1 | 2x1gigs Mushkin XtremePerformance DDR2 800 | 250gig SATAII Barracuda | X-Fi ExtremeGamer Pro Fatal1ty Edition | 750w Toughpower | Aurora 570 Case | 3dMark06 - 13,110
    Design By Humans

  7. #7
    Fragged
    Join Date
    May 2011
    Posts
    16

    Re: Anyone experienced in Matlab?

    Oh, matlab, i think that is a awesome software

Posting Permissions

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

Advertise:
Ads@StrafeRight.com

Terms of Service || Privacy & DMCA Policies || About Us
Powered by vBulletin® Version 4.2.2
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO 3.6.0

All times are GMT -4. The time now is 11:51 AM.
Design by DanFortH