Computer HardwareXbox GamesGameCubePlaystation 2PSOnePC/Windows GamesGameboy AdvanceDreamcastNintendo 64Gameboy ColorNintendo DSSony PSPXbox 360Nintendo Wii GamesPS3 Games

Neoseeker Forums » Programming and Design » General Programming » Need Help ASAP!

REPLY TO THIS THREAD   START NEW THREAD
| Sharemore
Options: Print   subscribe   remove   PM this thread to a friendNeoPM  
subscribe to thread Topic: Need Help ASAP!
Jak66
Hooked on Neo



Jak66's profileJak66's neohomeNeoPM Jak66
since: May 2003
Oct 04, 09 at 11:29pm
Need Help ASAP!

Okay, so for my computer class I am suppose to create an animated sprite with Visual basic Studio 2008. Our instructor did not explain the process well and now I am a little stumped. We need to take a regular sprite sheet e.g www.spriteresource.com and create an animated sprite with it on a background image. Would someone please describe how I do this? Or provide the coding?


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Chiggins
(devpen) (crs) (badass)
(moderator)

HTML/CSS & NeoHome Help



Chiggins' profileChiggins' neohomeEmail ChigginsNeoPM ChigginsChiggins' gallery (412 images)
total posts: 2485
neopoints: 204
GameGrep pts: 613
since: Jun 2003
Oct 05, 09 at 2:14am
re: Need Help ASAP!

Well, I never really got too much into it, but I would look into trying to use XNA with VB.



-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Mr Roboto
Freebies Rule
high on "N"



Mr Roboto's profileMr Roboto's neohomeNeoPM Mr Roboto
since: Jul 2004
Oct 05, 09 at 3:08am
re: Need Help ASAP!

If you do go the XNA route, know that VB isn't officially supported. This thread may help. http://forums.xna.com/forums/p/1464/7267.aspx#7267

The basic idea of a sprite sheet is only drawing a portion of it at a time. You draw a rectangle cut out of the entire sprite sheet one at a time and move the source rectangle over time. So if you had a 30 pixel wide and 30 pixel high sprite sheet and each frame was 10 pixels wide, you'd draw a 10x30 "cut out" starting at pixel 0, then after a certain amount of time has passed, you'd draw a 10x30 "cut out" starting at pixel 10 and finally you'd draw a 10x30 "cut out" starting at pixel 20. Once you reach the last frame, you'd start back over at pixel 0.

I wrote a basic animated sprite class that does just this a long while ago here http://infexxion.codeplex.com/SourceControl/changeset/view/14397#173139 It is in C# though.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Devastate
unwashed heathen
(moderator)

Action [PSP]



Devastate's profileEmail DevastateNeoPM Devastate
total posts: 922
since: Jul 2009
Oct 05, 09 at 1:24pm
re: Need Help ASAP!

Using XNA just to animate a sprite is overkill. Chances are that his teacher wouldn't want him to use XNA anyway.



-------------------
“You're only given a little spark of madness. You mustn't lose it.” - Robin Williams
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Millet
Five Elements is one more than 3D.
just getting started!



Millet's profileMillet's neohomeNeoPM MilletMillet's Fan Art!Millet's gallery (2 images)
total posts: 145
since: Mar 2009
Oct 19, 09 at 4:33pm
re: Need Help ASAP!

Hi, Jak66

This is in C++, but I provide it for you VB challenge since if you look up the names and Events, you get the same thing in less effort learning this stuff for yourself by "help" searches.

Just use what you know about VB, or get out your textbook, and fill the utility of your application.

It does not get much simpler than this, unless you have a function to do your sprite logic for you. Consider this,

Here is the recipe:

1) Make a Windows "Form"

2) Make however many Global "Bitmap"s you need for your sprites using ``gcnew Bitmap("yourimage.tiff")`` to create each one

3) Make one additional Local Bitmap in your OnPaint for the transfer from your Global Bitmaps to the Local Bitmap using GetPixel(..,..,.); SetPixel(..,..,.);

4) Use your OnPaint(PaintEventArgs^ e ) ``variable name of "e" `` ---like this: "e->Graphics->FillRectangle( Brushes::Black, 0, 0, this->Width, this->Height );" e->Graphics->DrawImageUnscaled(thisusesyourextra_Bitmap, thisusesa_Point);

5) Set your project options to DoubleBuffered = true

6) Set up your OnPaint to access variabletoeachsprite_Bitmap-> GetPixel(10, 300, thisuses_Color); bmpBitmap1->SetPixel(10, 300, thisuses_Color); except set a loop to cycle through the two integers which represent screen coordinates

7) This is a harder one: Organize a logic like if( e->Graphics->GetPixel(,,) != your_Color ){paint a pixel to your extra Bitmap } your Get and Set pixel operations therefore seem to choose to ignore a certain color while SetPixel(,,); the pixel of your sprite Bitmap's`` to your extra Bitmap`` as in: if that color is not read in the logic for your GetPixel(,,); so here is the KEY: instead of ignoring the logical-color- ignore pixel hit, use this "if- ---uh oh matched_up_to_color" to step past at all pixels the locations of those, so of your Get so that you place your Get and Set only to the pixels that transfer the logical color

8) Repaint your extra Bitmap to a background Color each time you need to update the sprite, and then using SetPixel will be as you rerender a sprite to your extra Bitmap before you update that to your window: e->Graphics-> DrawImageUnscaled(thisusesyourextra_Bitmap, thisusesa_Point);

9) Put a timer along a number of milliseconds delay like this: timer1 = gcnew System::Windows:: Forms::Timer; timer1->Interval = 1; timer1->Tick += gcnew EventHandler( this, &Form1:: OnTimer ); private: void OnTimer( Object^ /*sender*/, EventArgs^ /*e*/ ) { this->Refresh(); }

10) If necessary set a background color to your Window like this: e->Graphics->FillRectangle( Brushes::Black, 0, 0, this->Width, this->Height );

11) Build your program, and clean up the offset at which your extra Bitmap is drawn to the Window so that your sprites come onto the Window looking the right way

0) The thing inside these philobracks: |this->Refresh();| ---triggers your OnPaint every time the refresh is called, so in your timer Tick handler first set which is the current `iteration[int number]' number as which of your Bitmap will go to your extra Bitmap, and put your this->Refresh(); afterward

12a) If necessary use an image conversion program like Paint or GIMP, or whatever you can find for free (there are a number), so if you find some sprites you like, but find that they are not a format supported by your Visual Studio 2008, or whatever you are using (2008Ex is a free download from Microsoft [r), you convert those sprites to the right format, being !!careful!! to choose one that will handle transparency the right way, since some will just set the default color where transparency should have been used, leaving you with no fun 12b) that is about it, so I hope that helps.

12c) So here is a reminder, these are what Microsoft calls their C++<types>, by which you can look up the VB types: "Bitmap, Color, Point, int, Graphics --associated: PaintEventArgs^ e " noting that I sorta named the variables in this recipe appropriately to give you a clue

12d_A:) Note that you have to make one event handler (for your timer), so make declare your timer object: public: System::Windows ::Forms:: Timer^ timer1; so these are the calls that you place inside of your "constructor"'s brackets in some appropriate location therein: timer1 = gcnew System::Windows :: Forms::Timer; timer1->Interval = 1; timer1->Tick += gcnew EventHandler( this, &Form1:: OnTimer ) ;

12d_B:) Whereas this is the function for the timer Event Handler: private: void OnTimer( Object^ /*sender*/, EventArgs^ /*e*/ ) { this->Refresh(); }

12e) See to it that your Bitmaps and such look kind of like this, in the public class namespace--- public: System ::Windows::Forms:: Timer^ timer1; Byte whatdoyouneedonlyone_Byte_for; Bitmap^ Bitmap0-sprites_minus1; bool trueORfalse; Point screenCoordinates; int countforCoordinates_etc;

12e_A) Of course name your variables appropriately

13) Use for you logic something like if(conditional){logics;}else{logics;} |---->oryoucoulduse:---->| switch( expression ) { case 'constant_expression0' : x++; break; case 'constant_expression1' : y++; break; case 'constant_expression2' : z++; break; }

14) So do not get frustrated, since I believe this list here covers you pretty well


Anyway, this is the source for that:


#pragma once

using namespace System::Windows::Forms;

namespace My_SprtS {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:: Data;
using namespace System:: Drawing;

public ref class Form1 : public System::Windows:: Forms:: Form
{

public:

System::Windows:: Forms::Timer^ timer1;
Byte yourMode_ofuse_bytesize;
Bitmap^ yourBitmap1;
bool isTrueor_notTrue;
Point uPoint_toplace_aBtmp;

Form1(void)
{
InitializeComponent();

/// <summary>configure the Form :</summary>
this->Resize += gcnew EventHandler( this, &Form1:: OnResize );
this->Click += gcnew EventHandler( this, &Form1::ViewsHandler );
this->
timer1 = gcnew System::Wind ows::Forms: :Timer;
timer1->Interval = 1;
timer1->Tick += gcnew EventHandler( this, &Form1:: OnTimer );

/// <summary>Load your Bitmaps here
/// ...
/// </summary>

/// <summary>Set a sprite Color here</summary>

/// <summary>Refresh your Window if you want to:</summary>
this->Refresh();
}

protected:
/// <summary> Paint;.... </summary>
virtual void OnPaint( PaintEventArgs^ e ) override
{
/// <summary>Draw your 'extra Bitmap' to your Window here
}
~Form1()
{
delete bufferingModeStrings;
if (components)
{
/// <summary>Use delete on your Bitmap objects releases that memory, and the device information that the system uses</summary>
delete bmpBitmaps0-1minus1plus1;
delete components;
}
}

private:
void OnTimer( Object^ /*sender*/, EventArgs^ /*e*/ )
{
/// <summary>Set state values and iterator bytes and integers First</summary>
/// <summary>Second, respond to your state variables by choosing cueing in a Bitmap for your SetPixel and GetPixel to use; per values set in OnTimer; so do all of your Bitmap operations which are prior to rendering but after a timer Event, here</summary>
this->Refresh();
}
void OnResize( Object^ /*sender*/, EventArgs^ /*e*/ )
{
this->Text = "You resized your application Window!";
this->Refresh();
}

System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
// <summary>Form1</summary>
this->AutoScaleDimensions = System:: Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::For ms::A utoScaleMode::Font;
this->AutoValidate = Sys tem::Windows:: Forms::AutoValidate::E nableAllowFocusChange;
this->ClientSize = System:: Drawing::Size(814, 562);
this->DoubleBuffered = true;
this->Icon = (cli::safe_cast<Sy stem:: Drawing ::Icon^ >(resources->GetObjec t(L"$this.Icon")));
this->Name = L"Form1";
this->Text = L"Your_SpriteApp";
this->Load += gcnew System::EventHandler(this, &Form1::F orm1_Load);
this->ResumeLayout(false);

}
#pragma endregion
private: System::Void Form1_Load(Syste m:: Object^ sender, System::EventArgs^ e) {
}
};
}


-------------------
Manifest Artistry.
quote   quick quote   edit   quick edit   del  searchposts in thread  report
[All dates in (PT) time]Threads List   « Next Newest   Next Oldest »
REPLY TO THIS THREAD   START NEW THREAD


search:
search posts by username:
Neoseeker Forums » Programming and Design » General Programming » Need Help ASAP!



Jump to another forum:

Powered by neoforums v0.9.8b (equilibrium)
Copyright Neo Era Media, Inc. 1999-2009

neoseeker forum community
Neoseeker.com   |   Forum Rules   |   Forum FAQ   |   Neoseeker Terms of Use   |   Supermods On Duty [ server id: ascension ··· elapsed: 0.1129457951]
Affiliated sites:   GameGrep - Football Manager Wiki - Halo Wiki - MGS Wiki - GTA Wiki - Smackdown Wiki - Zelda Wiki - PS2seeker - Xbox seeker - DEVPEN - GFXcess